public void SignalToStop( ) { lock ( sync ) { // stop thread if ( thread != null ) { // signal to stop stopEvent.Set( ); } } }