Question related to multi-threading

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

Hi:

I'm running a thread that displays a messagebox. I want the messagebox to
close when the thread aborts, but I've had no luck in doing so. A simple
call to thread.abort doesn't work. Anyone know what I may be doing wrong?
 
Roger,

The messagebox is a modal dialog that waits for the user to dismiss it.
The only way you will be able to shut it down is to find the windows handle,
and send a message to it (which isn't the easiest to find).

You might want to think of some sort of event notification that fires
when your thread is done processing, as well as some custom display that you
can easily hide/dispose of when the event notification is fired.

Hope this helps.
 
Thanks


Nicholas Paldino said:
Roger,

The messagebox is a modal dialog that waits for the user to dismiss it.
The only way you will be able to shut it down is to find the windows
handle, and send a message to it (which isn't the easiest to find).

You might want to think of some sort of event notification that fires
when your thread is done processing, as well as some custom display that
you can easily hide/dispose of when the event notification is fired.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Roger said:
Hi:

I'm running a thread that displays a messagebox. I want the messagebox
to close when the thread aborts, but I've had no luck in doing so. A
simple call to thread.abort doesn't work. Anyone know what I may be
doing wrong?
 
Keep all things related to user-interface in the primary thread (and vice
versa - i.e. the primary thread doesn't have to deal with anything else other
than the UI, that way it shouldn't get blocked up).
Then just transfer control back to the primary thread in order to display
the message box. The main form then won't be able to be closed until the
message box is dismissed.
 
I got the same problem with that as well, could you please give me a sample
of code how to do so. Thank you
 
Back
Top