private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
m_bActive = false;
if(m_HandlePacketThread != null)
{
// NOTE: When the form is closing why would we Join and then Abort a thread? Otherwise when we get here and no thread has started there
// NOTE: is an exception for a null reference.
m_HandlePacketThread.Join();
m_HandlePacketThread.Abort();
}
// NNOTE: Here too. If the thread hasn't started yet then there is no object to test. Nothing but exceptions here..
if (m_NetServer != null)
{
foreach (ConnectedClient c in m_NetServer.m_ConnectedClientList)
{
c.m_Socket.Shutdown(SocketShutdown.Both);
c.m_Socket.Disconnect(false);
c.m_Socket.Close();
}
m_fLogFile.Close();
m_NetServer.Stop();
}
}