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