I'm developping a C# app in Windows using VS2010. It has one form and communicates as a client with a server.
A receive thread displays incoming data while buttons and a timer send data. All working.
The form has a button that calls the below method to disconnect from the server.
Code:
public bool disconnect()
{
keepalive_timer.Enabled = false;
keepalive_timer.Dispose();
keepalive_timer = null;
bActive = false;
tidListen.Abort();
myClient.Close();
bConnected = false;
return false;
}
It disconnects (I think
) and if I close the form after that, my debug session ends.
I'm however fighting a lost battle to properly stop the application if I close the form using the 'X'. I catch the FormClosing event and call the same disconnect method. But something keeps on running (possibly the thread) and I have to end the debug session manually.
Any pointers where to look or what I'm missing are appreciated.
Thanks in advance,
wimS
PS
The problem was already there before I started using a timer, so I don't think it's in the timer.