M
Markus Ewald
I created a simple splash screen with a progress bar in it that should
keep the user entertained while my application is busy loading resources.
The code goes like this:
// Display the loading splash screen while we're busy.
using(StartupForm loadingScreen = new StartupForm()) {
loadingScreen.Show();
loadResourcesThread.Start();
loadResourcesThread.Join();
loadingScreen.Close();
}
What I expected was that the loading screen would still be kept
responsive (MSDN on Thread.Join(): "Blocks the calling thread until a
thread terminates, while continuing to perform standard COM and
SendMessage pumping"). What happens instead is that the splash screen
uses the hourglass cursor and doesn't redraw its controls while the main
thread sits in loadResourceThread.Join().
It works as expected if I use an ugly hack like this:
loadResourcesThread.Start();
while(loadResourcesThread.IsAlive)
Application.DoEvents();
loadResourcesThread.Join();
So is executing the message pump not enough to keep the UI in a .NET
application responsive?
Thanks ahead,
-Markus-
keep the user entertained while my application is busy loading resources.
The code goes like this:
// Display the loading splash screen while we're busy.
using(StartupForm loadingScreen = new StartupForm()) {
loadingScreen.Show();
loadResourcesThread.Start();
loadResourcesThread.Join();
loadingScreen.Close();
}
What I expected was that the loading screen would still be kept
responsive (MSDN on Thread.Join(): "Blocks the calling thread until a
thread terminates, while continuing to perform standard COM and
SendMessage pumping"). What happens instead is that the splash screen
uses the hourglass cursor and doesn't redraw its controls while the main
thread sits in loadResourceThread.Join().
It works as expected if I use an ugly hack like this:
loadResourcesThread.Start();
while(loadResourcesThread.IsAlive)
Application.DoEvents();
loadResourcesThread.Join();
So is executing the message pump not enough to keep the UI in a .NET
application responsive?
Thanks ahead,
-Markus-