Salat
Regular
I'm useing sucha a code for splash screen, which is shown while the main form is loading. There is a panel which is fluently flickering, as a progress of loading. The 'sta' integer is used to wait for splash screen to show properly.
Here is how it works:
- the splash screen is shown, the second of time is remebered by sta
- is Now.Second is other then at the start, then the Form1Loading in parent class is called
- form this form1loading, there is a new threat created and it is run
- from form1loading at class ThreadForm1Loading there is a Form1 loaded, and shown
- if it all is done, the program ends
Is it possible to load Form1 from other thread and do not end programm executing?
thanks for help...
Here is how it works:
- the splash screen is shown, the second of time is remebered by sta
- is Now.Second is other then at the start, then the Form1Loading in parent class is called
- form this form1loading, there is a new threat created and it is run
- from form1loading at class ThreadForm1Loading there is a Form1 loaded, and shown
- if it all is done, the program ends
Visual Basic:
Imports System.Threading
Public Class Form4
Inherits System.Windows.Forms.Form
Dim LoadingProgress As Integer = 120
Dim LoadingProgressDirection As Boolean
Dim sta As Double
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Application.DoEvents()
Dim i As Integer = LoadingProgress
Panel1.BackColor = Color.FromArgb(i, i, i)
If LoadingProgressDirection = True Then LoadingProgress = i + 20
If LoadingProgressDirection = False Then LoadingProgress = i - 20
If LoadingProgress > 255 Then LoadingProgress = 255 : LoadingProgressDirection = False
If LoadingProgress < 120 Then LoadingProgress = 120 : LoadingProgressDirection = True
End Sub
Public Sub Form4_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
sta = Now.Second
Timer1.Enabled = True
Call Form1Loading()
End Sub
Private Sub Form1Loading()
Do While sta = Now.Second
Application.DoEvents()
Loop
Dim oThread As New ThreadForm1Loading()
oThread.mi = Me
Dim otter As New ThreadStart(AddressOf oThread.Form1Loading)
Dim oThr As New Thread(otter)
oThr.Start()
End Sub
Class ThreadForm1Loading
Public mf As Form1 = Nothing
Public mi As Form = Nothing
Sub Form1Loading()
mf = New Form1()
Application.DoEvents()
mf.Show()
mi.Visible = False
Do
Application.DoEvents()
If mf.Visible = True Then Exit Do
Loop
mi.Visible = False
End Sub
End Class
End Class
Is it possible to load Form1 from other thread and do not end programm executing?
thanks for help...