Showing Form in New Thread?

L

Lars Netzel

Hi

I have a Form that on Form_Load() does some heavy database reading and I
want to show that as a progressbar ontop of the main window..

I want to create a smaller Form with a progressbar.. and then in the main
form, start a new thread that opens that small form and for each progress
the heavy operation send a new value to the small form thru an event.

I have managed to run a function or a sub in another thread but I can't
figure out how to load a whole window in a new thread and keep sending new
messages to it?

Working with VB.NET and framework 1.1

best regards/
Lars Netzel
 
B

Brian Gideon

Lars,

The best to do this is to create and update the progress bar form in
the main UI thread. The worker thread will use Invoke or BeginInvoke
from an existing Form to marshal the execution of a delegate onto the
UI thread to accomplish this.

Brian
 
O

Olie

Idealy you should not be calling Window functions from anything but the
main AppDomain thread. You should call Invoke on any form control or by
getting the AppDomain thread object.

You then need to Invoke a function that will launch the Dialog. You can
signal to the Dialog using the same method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top