I'm working on a WinForm application with .NET CF 2.0 and I have a background running thread that needs to notify the user about various events. The problem is that everytime I want to notify the user with a MessageBox about an event, the application exits once the messagebox is displayed...I get the following message in the output window: The thread 0x2eda2a2 has exited with code 0 (0x0).
However, if I display the message in a label of my form, everything works well...here is the code I use:
Expand|Select|Wrap|Line Numbers
- public void DisplayMessage(string message)
- {
- if (InvokeRequired)
- {
- DisplayMessageDelegate displayMessageDelegate = new DisplayMessageDelegate(DisplayMessage);
- this.Invoke(displayMessageDelegate, new object[] { message });
- }
- else
- {
- this.labelStatus.Text = message; // Works well
- MessageBox.Show(message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); // Application exits when called
- }
- }
alex