private void StopMonitorThreads() { lock (monitor) { if (monitorStarted.CompareAndSet(true, false)) { // Attempt to wait for the Timer to shutdown, but don't wait // forever, if they don't shutdown after two seconds, just quit. ThreadUtil.DisposeTimer(connectionCheckTimer, 2000); this.asyncTask.Shutdown(); this.asyncTask = null; this.asyncWriteTask = null; } } }