|
-
Feb 27th, 2007, 10:29 AM
#1
[2005] Threading Cross Form
I have an app that does a bunch of stuff at startup before the main form is shown.
During this startup period, I don't show a splash screen, but there is a "wait please contacting server" form, which is just a form with a label and picturebox. The picturebox has an animated gif in it to show that the app is not frozen.
Now the issue I have is this:
I show and hide this form a number of times during this startup depending on how the startup process goes. For example, the first thing the app does is test for an internet connection, if it cant find one, it comes up with a form to tell them so, and displays any potential firewalls they have installed. However if the app finds an inet connection no problem, the firewall form is never shown, and it goes onto the next step of the startup routine (etc...)
What I need to be able to do, is make calls to show or hide this "wait" form at any given time. However while I don't care if the wait form is shown modally or not (because I set it to topmost, and any forms behind it are disabled while the wait form is showing), I do need it to be in its own thread, otherwise the animated gif doesn't animate. I assume this is due to the message looping somewhere.
So in the wait form I have a method called ShowMe() and it launches the wait form in its own thread, however I need to also have a HideMe() that will hide the form.
I guess what I am a bit stuck on, is how to make the cross thread calls. I have done cross thread calls before, but usually its when the seperate thread is doing some background work, and needs to update the UI, this is a bit different in that the main application thread is doing the background work, and the new thread should be showing this wait form.
So I need to figure out how to access the form on this seperate thread from my main thread, but from 2 different routines.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|