E
Elie
Hi all,
I m doing initialization on the startup of my app like loading the
dataset and the forms that contain lots of control, to improve
performance.
Since it's taking long time i decided to display a splash screen that
will run until the initialization is completed
i downloaded the code of the splash screen from msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetco
mp/html/casoast.asp?frame=true
this is the code in the load event handler of the main form:
Dim splashThread As Thread = New Thread(New ThreadStart(AddressOf
StartSplash))
splashThread.Start()
' Pretend that our application is doing a bunch of loading and
' initialization
Thread.Sleep((kMinAmountOfSplashTime_ms / 2))
' Sit and spin while we wait for the minimum timer interval if
' the interval has not already passed
While splash.GetUpMilliseconds() < kMinAmountOfSplashTime_ms
Thread.Sleep((kSplashUpdateInterval_ms / 4))
End While
' Close the splash screen
CloseSplash()
in this sample the splash screen run in another thread for a specific
amount of time and after that it's closed and the main form appears. but
since i don't know how long my initialization will take, i was thinking
of the folowing scenario:
1- main thread starts
2- splash screen thread starts and loop for ever
3- initialization starts on the main thread
4- when initialization finish call the CloseSplash
now I m not sure how to do the 4th step.Can the splash screen thread
wait for a variable in the mainthread to change (and how to do that).
how the main thread will signal to the splash screen thread that
initialization has finished and the splash screen should be closed.
should i use the ManuelResetEvent class , or should i use asynchronous
call with beginInitialize and endInitialize.
I never used these classes before or worked in multi threading
application, so i m wondering what to do.
thank you.
I m doing initialization on the startup of my app like loading the
dataset and the forms that contain lots of control, to improve
performance.
Since it's taking long time i decided to display a splash screen that
will run until the initialization is completed
i downloaded the code of the splash screen from msdn:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetco
mp/html/casoast.asp?frame=true
this is the code in the load event handler of the main form:
Dim splashThread As Thread = New Thread(New ThreadStart(AddressOf
StartSplash))
splashThread.Start()
' Pretend that our application is doing a bunch of loading and
' initialization
Thread.Sleep((kMinAmountOfSplashTime_ms / 2))
' Sit and spin while we wait for the minimum timer interval if
' the interval has not already passed
While splash.GetUpMilliseconds() < kMinAmountOfSplashTime_ms
Thread.Sleep((kSplashUpdateInterval_ms / 4))
End While
' Close the splash screen
CloseSplash()
in this sample the splash screen run in another thread for a specific
amount of time and after that it's closed and the main form appears. but
since i don't know how long my initialization will take, i was thinking
of the folowing scenario:
1- main thread starts
2- splash screen thread starts and loop for ever
3- initialization starts on the main thread
4- when initialization finish call the CloseSplash
now I m not sure how to do the 4th step.Can the splash screen thread
wait for a variable in the mainthread to change (and how to do that).
how the main thread will signal to the splash screen thread that
initialization has finished and the splash screen should be closed.
should i use the ManuelResetEvent class , or should i use asynchronous
call with beginInitialize and endInitialize.
I never used these classes before or worked in multi threading
application, so i m wondering what to do.
thank you.