private void Receiver_LogReceived(object sender, LogReceivedEventArgs e)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() => {
         lock (ViewModelConstants.SYNC_OBJECT) {
             // Add a log entry only to the list if global logging is active (checkbox)
             if (!IsActive)
             {
                 return;
             }
             LogViewModel log = ToLogViewModel(e.Log);
             LogsToInsert.Add(log);
         }
     });
 }
        private void Callback(Object state)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() => {
                // TODO: Refactor this so we can use using(...)
                Stopwatch sw = new Stopwatch();
                lock (ViewModelConstants.SYNC_OBJECT) {
                    var logsToInsert = LogsToInsert.OrderBy(m => m.Timestamp);

                    // 1. Add missing applications using incoming logs
                    sw.Start();
                    UpdateApplications(logsToInsert);
                    sw.Stop();
                    if (ApplicationConfiguration.IsTimingTraceEnabled)
                    {
                        Logger.Trace("[UpdateApplications] " + sw.ElapsedMilliseconds + "ms");
                    }
                    // 2. Add missing namespaces using incoming logs
                    sw.Restart();
                    UpdateNamespaces(logsToInsert);
                    sw.Stop();
                    if (ApplicationConfiguration.IsTimingTraceEnabled)
                    {
                        Logger.Trace("[UpdateNamespaces] " + sw.ElapsedMilliseconds + "ms");
                    }

                    sw.Restart();
                    AddLogs(logsToInsert);
                    sw.Stop();
                    if (ApplicationConfiguration.IsTimingTraceEnabled)
                    {
                        Logger.Trace("[UpdateLogs] " + sw.ElapsedMilliseconds + "ms");
                    }

                    LogsToInsert.Clear();

                    Timer.Change(TIME_INTERVAL_IN_MILLISECONDS, Timeout.Infinite);
                }
            });
        }