Reputation: 199
Two Forms 1. "SplashForm" 2. "MainForm"
I want to load "MainForm" AS background Process of "SplashForm" process when "SplashForm" process end i just want to show the "MainForm" which should be already loaded code
VB Code:
Imports System
Imports System.Threading
Public Class MultiThreading
' Global declaration
Dim mf As New MainForm
'Thread Declaration
Dim tm As New Thread(AddressOf LoadProcess)
Dim ts As New Thread(AddressOf Splashprocess)
Private Sub Epaper_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Opacity = 0
tm.Start()
ts.Start()
End Sub
Sub LoadProcess()
mf.Show()
mf.Hide()
End Sub
Sub Splashprocess()
For i As Integer = 0 To 1000
Me.Opacity += 0.01
Next
If Me.Opacity = 1 Then
mf.Show()
Me.Hide()
End If
End Sub
End Class
Upvotes: 0
Views: 795
Reputation: 993
Why don't you call the SplashScreen from the main form? Your main form should be invisible at first. When the main form is loaded, You could first of all show the splashscreen as an independant form (not child), then proceed on loading your main form. When all the process is done, dismiss the splashscreen and show the main form.
Therefore, you would avoid using homemade threads.
Here is a pseudo-code exemple :
In Main_Form class // which is invisible
{
When Main_Form is loaded
{
Show SplashScreen
Proceed on loading everything else
Hide SplashScreen
Show Main_Form
}
}
Upvotes: 1