"alex" <ai******@hotmail.com> schrieb
Fergus,
I am not quite sure if i understand you correctly...
an MDI form in my application has a distinctive task. I have build
another class that handles various table updates/manipulation. like
getTable, updateTable etc.
Here is what I need to do.
1. I want to start the update
2. I want to show a progress bar
3. I want to prevent users from changing the form untill the update
is
completed.
4. While running the update the user should be able to do different
things.
Now, if I run the a thread per db connection then i blieve the user
can still manipulate the form. Though this could be done for the
form waiting to complete... but then what is the difference in
running the form as a thread.
Sorry, guess I am too new for that topic. Am just a bit frustrated
that the gui freezes for 10 min.
If you put the work in a different thread, the GUI does not freeze. I'd put
the work in a separate class (a kind of worker/thread class) and raise
abstract events (DoneThis, DoneThat, Progress...). The UI can catch the
events. As the event handlers in the UI also run in the other thread, i.e.
not in the thread that created the UI/Form, you have to marshal the UI
update to the thread that created the Form by calling Invoke/BeginInvoke.
Of course, your UI and the rest of the application has to take care of the
fact that there is something running in the background and you may come
across conflicts or inconsistences. You have to deal with them - the answer
how to do it is very individual. An MDI environment might be the worst
scenario - so modally showing a (responsive) Form containing a progressbar
and a cancel button is probably the easiest solution.
--
Armin