Multiple forms thread example

JonathanVP

Newcomer
Joined
Dec 9, 2004
Messages
1
I have a couple of questions which I need resolved so please bear with me:
1. I have a vb.net app that uses a timer to read in documents. I have implemented progress bars to display the process but they don't repaint or refresh properly. Also, they loose focus. Is there anyway to fix this so that the progress bars display properly?
2. Is there any multi-threaded vb.net examples that uses multiple forms? All the examples I find on the net uses the console.
Thanks,
Jonathan
 
problem 1:
The timer you are using, uses its own thread. This means that it tries to update the GUI from a non GUI thread. You can search in this forum for 'begininvoke' to find some examples how to deal with this.

problem 2:
What does using multiple forms have to do with multithreading?
What I mean is, when you start using multithreading, you must always handle the situation where you try to update the GUI from a thread where you're not allowed to do so (and thus use invoke, see problem 1). Having multiple forms doesnt make it more complex, it just means that you have to use that same mechanism in more places.
All the synchronization principles that (should be) in the console examples, still apply, only the GUI-update issue is added when starting to use forms.
I think there are some examples in this forum on using threads (with and without forms), you might try searching for 'threading'.
 
There is a great Threading example on this site http://zone13.net/zone13/default.asp?PageAction=TECHTALK&TechID=539.

Slight modification to the class you could change the LongProcess sub to your document load sub. And then pass the necessary values in the New sub of the class. each time you try to load a new document say something like this

Dim MyNewDocumentLoadingThread as new classThread("C:\PathToMyDocument\")

Or something along those lines.
 
Back
Top