views:

108

answers:

1

After I added the following code to my code-behind, my form doesn't get closed.

Could you please help me out with this one?

private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
    MyThreadingObj.Dispose();
}
+2  A: 

It sounds like adding the above code prevents your Form from closing. If so then the most likely cause is that the MyTHreadingObj.Dispose() statement is throwing an exception. Try wrapping the statement in a try/catch and seeing if this is the case

try {
  MyThreadingObj.Dispose();
} catch ( Exception e ) { 
  Console.WriteLine(e);
}
JaredPar