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

FormProgress.show()
'
'Several lines of code
'
form2.show()


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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.