I have a program where it takes about 4-6 seconds to load(lets call it form2). form2 has a lot of code so what I want to do is create a progress bar.

Form1 has the button that takes me to form2.

So what I want to do is load a new form that has a progressbar(FormProgress), so when the user clicks on Form1 it opens FormProgress and loads the progressbar then closes it after form2 has loaded.

I know i need to use a second thread but I don't really know how to use it for that purpose.

My code has

'Several lines of code

Another problem I have is that FormProgress is frozen until form2 is loaded completely So my second thread runs but FormProgress does not load the progress bar until form2 is loaded.

Can someone also point me to a very good tutorial that is understandable how to Invoke & and using Delegates so i can learn it correctly. Thanks

5 Years
Discussion Span
Last Post by AnkitGuru

Thanks that somewhat worked. The Problem is that it starts loading the progressbar after it finished the code from the other Form. So it stays frozen until code from the form with the extensive code then it starts loading the progress bar.


It looks like you need to create a new Thread. This will salve the issue of frozen form. Put the time consuming code onto this thread, and use a progressBar to show the updating of the work.
Instead of using Thread you can use Backgroundworker class.


instead of creating a new thread i suggest that u should rather create a public variable on form2 and update its value( value might suggest the load_status)
now create a new sub on form1 that can access the value of the variable.
use a timer or new thread whichever u like. and update the status of the progress bar according to the above code.This will give u a real time update status

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.