MDI Child as Thread

  • Thread starter Thread starter alex
  • Start date Start date
A

alex

Hi,
i am doing a db update in an mdi child and for the process of the update
(several minutes) the child freezes the entire screen.

could someone help me to on how to run an mdi i child as a thread ? I
suppose thats the way to do it.

I want the to prevent that the form is freezing the entire application
and screen and also want to work on other forms while the update is in
progress.

Thanks a lot for any suggestion and help

Alex
 
Hi Alex,

You wouldn't run an Mdi child as a thread per se. What you would do is run
the db update within a Thread. This makes your question much simpler because
you can forget the Mdi bit.

There's plenty of documentation on MSDN for Threads. I posted a Threading
example to someone only tonight. It might be more than you need but then
again, it might be useful. ;-)

Topic: New to threading.. Please help.., dated 21st Oct.

Come back with any further questions.

Regards,
Fergus
 
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.

Alex
 
alex said:
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.
 
Back
Top