Problem with Message Box from Thread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to show a message box from a thread I'm running. Every time it
executes, it takes me back to the main main screen without showing up. Here
is what I'm doing:

Starting a main window
Starting a 2nd window (2ndwindow.show) that in turn starts a background
thread when a button on it is pressed.

I'm calling a routine in the 2nd Window from the background thread using a
delegate. This works fine if I just have this routine update a textbox in
the 2nd Window but if I try to have it show a message box, I fail. It looks
like the message box quickly pops up and then I go back to my main screen.

Any ideas of how to handle this?
 
I'm calling a routine in the 2nd Window from the background thread using a
delegate. This works fine if I just have this routine update a textbox in
This should nothave worked - you are just being lucky. Change it to use
ControlInvoke:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

In the method you controlinvoke to, show the messagebox. Note that
technically you can MessageBox.Show from another thread so I don't know what
problem you are facing there. Touching textboxes and other form elements
though must be changed as suggested above.

Cheers
Daniel
 
I'm doing exatly what you noted below. Even if I try to display the message
box from the background thread, I get the same results. The message box
briefly displays and then the start window shows up again. I'm guessing the
message box may be behind the start window.

Ron

Daniel Moth said:
I'm calling a routine in the 2nd Window from the background thread using a
delegate. This works fine if I just have this routine update a textbox in
This should nothave worked - you are just being lucky. Change it to use
ControlInvoke:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

In the method you controlinvoke to, show the messagebox. Note that
technically you can MessageBox.Show from another thread so I don't know what
problem you are facing there. Touching textboxes and other form elements
though must be changed as suggested above.

Cheers
Daniel
 
I found my problem. It had to do with an event that was firing and closing
my form from which the message box originated.

Ron

RonF said:
I'm doing exatly what you noted below. Even if I try to display the message
box from the background thread, I get the same results. The message box
briefly displays and then the start window shows up again. I'm guessing the
message box may be behind the start window.

Ron
 
Thanks for the update... I was going to ask you to post a complete example
cause I was getting confused but no need now...

Cheers
Daniel
 
Back
Top