/// <summary> /// Clears up the singleton if it was setup. /// shuts down the WorkerThread if it was started. /// clears up the outputters. /// </summary> public override void Dispose() { if (_singleton) { LOG.ClearSingleton(); } _handlingInProgress.WaitOne(); _handlingInProgress.ReleaseMutex(); if (_workerThread != null) { //Signaling thread to shut down _shouldRun = false; //Making sure All messages got handled _waiter.Set(); //Waiting for the thread to complete its work _workerThread.Join(); } //handling all messages missed by the worker thread ProcessMessages(); foreach (ILogOutput outputter in _outputters) { outputter.Dispose(); } _handlingInProgress.Dispose(); }