public void WaitForDisconnect() { if( ioThread != null && ioThread.IsAlive ) { try { ioThread.Join(); } catch( NullReferenceException ) { } catch( ThreadStateException ) { } } }