I have following code
private void btnClose_Click(object sender, System.EventArgs e)
{
Close();
} // btnClose_Click
After running the close winforms function the application freezes. Any idea why it can happen?
I use .net 2.0 and i run under Windows 7 vs2005
EDIT:
After I pressed pause in the debugger I came to
private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// GUI
if (FScannerThread_Running)
{
FScannerThread_Running = false;
FScannerThread.Join();
}
}
And it stacked in FScannerThread.Join(); any idea how i can kill it ?
Use the
bool Thread.Join(int milliseconds)overload, and if the result is false,Abort()your thread.Note that you should catch
ThreadAbortExceptionin your thread in order to end it gracefully (if you have something to release for instance).