private void ProcessQueue() { var token = _tokenSource.Token; while (!token.IsCancellationRequested) { LogMessage logMessage; try { logMessage = _logQueue.Take(_tokenSource.Token); } catch (OperationCanceledException) { break; } logMessage.Format(); try { ForwardToLogTarget(logMessage); ForwardToListeners(logMessage); } catch (Exception ex) { // Well, how do we log if the logger throws exceptions. :D CrashHandler.WriteErrorToFile("Caught exception while logging! Exception: " + ex.Message); } } }