private static void ProcessMessage() { INotMsg msg; if (System.Threading.Interlocked.CompareExchange(ref _msgProcessBusy, 2, 1) != 1) { return; } while (_msgs.Any()) { if (_msgs.TryDequeue(out msg)) { try { //Log.Debug("Tick: {0}", msg.ToString()); msg.Process(); } catch (Exception ex) { Log.Warning("App.ProcessMessage(0) - {1}", msg, ex.ToString()); } } } _msgProcessBusy = 1; }