I've run across something wierd under Windows Mobile 5.0, Compact Framework 2.0.
I've got a custom control that (by design) throws an exception when someone clicks a button on it.
However, in the corresponding catch statement, when I use a messagebox, the messagebox pops up and displays its message, but the program continues running past this point, not waiting for the user to click OK, and past another messagebox which also pops up its message, and then the application just shuts down.
I've looked into this a bit and some people suspect threading of being able to throw up this sort of thing - i'm not using multiple threads, at least, not explicitly.
Heres the code;
Heres code for a button on the main form:
private void buttonSeekDevice_Click(object sender, System.EventArgs e)
myCustomClass logger = SeekDevice();
if (logger != null)
if (MessageBox.Show("No device found, continue searching?", "MyAppName", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.OK)
//this messagebox also pops up imediately after the exception is caught
//and then the application exits
Which calls this. When I click a button on the custom control displayed by ShowProgressWindow(), it throws an exception of type myCustomException.
private myCustomClass SeekDevice()
myCustomClass logger = null;
ShowProgressWindow(); //this is the custom control
anotherCustomClass searcher = new anotherCustomClass();
logger = searcher.Find(); //this can take a few minutes to run, giving user time to click a button which throws a myCustomException
catch (myCustomException mce)
//this exception is thrown when you click the right button
MessageBox.Show(mce.Message); //this shows up
MessageBox.Show("stop here"); //this also shows up immediatley, not waiting for you to click on the box above
return null; //and this is returned triggering the other messagebox to also show up in buttonSeekDevice_Click above
After the 3 messageboxes in the code above show up, the main form exits for no apparant reason. Any ideas??