Window form problem time consuming process

lamnic

Member
Joined
Apr 11, 2006
Messages
6
Programming Experience
Beginner
Now I have a window form which will run some time-consuming logic. So I want to create another thread to execute another window form which will serves as a progress bar form before I start the time-consuming logic in the main form. And then after the main form finished all its logic, it will close this progress bar form.
How can I do that?
Thx very much.
 
In this case i personally think it would be better to do the time consuming task on a different thread, leaving to main UI still responsive to the user. Then instead of creating a new form, just dynamically create a panel and a progress bar on plonk it on the screen.
If your time consuming task is in a separate class you can place an event in there, oh i dunno, lets call it..

Public Event UpdateProgressBar


Raise the event at the end of every iteration of the loop, or what ever it is your doing.

Then in your main class create a instance of the time consuming class declaring it 'WithEvents' Then open the event handler in the main class and have it update the progress bar. This way, with a few calculations atleast your progress bar will update with the work being done.(I've known some people just time how long it takes then set up the progress bar accordingly, not very professional)
All this can be done on a delegate with an asynchronus callback, on the callback sub all you need to do is check the invokerequired property, if all is ok, close the panel and your job is done.
I've just realised that i really need to put some code in here because that example i described, although very clear to me, probably makes no sense at all. I'll try to post a code example a bit later.
 
Back
Top