Termination of a form..

  • Thread starter Thomas Johansen
  • Start date
T

Thomas Johansen

Hi

I do have problems doing the follwing.

I create a new form form a thread in my application by using
Application.Run(myForm). Thats works fine, but how do I terminate that form
again ?. The only way I can do that without an ThreadAbortException is to
press the cross in the menu bar, but it schould close itself when job is
done without a user to do so. (I cannt handle the ThreadAbortException in
comapct framework)
Is it possible to make it terminate it self, or is there any why of closing
it?

If I call the ShowDialog() within its constructor I can close it without an
exception, but then I have to move the mouse across the dialog, before
something is shown.

How can I make the dialog update it self, so its shown when created ?

Any helt appriciated..

/Thomas
 
G

Guest

And it's generally very bad practice to launch a UI from a worker thread.
The UI should be in one, and only one thread - and that is the primary
thread that the precess entered on.

What are you trying to achieve by having it in a separate thread?
 
T

Thomas Johansen

My main form is launching a thread that is doing some tasks. Status of those
task are then send to the main form for displaying.
At some point, there is a need for showing a completly new form with some
info to the user.

I guess I could make the main form start that new form instead, and
terminate it again when done ??!?
 
G

Guest

The worker thread should post messages back to the primary thread for
display. A new thread for the UI is definitely a bad idea.
 

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