Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Answers
Problem displaying a messageBox
Alex
17y
2.7k
1
Reply
Hi,
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:
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
}
}
Thanks in advance!
alex
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
Exercises in C#
problem with datagrid