public void NewNotification(ToastData data)
 {
     lock (_lock)
     {
         _toastQueue.Enqueue(data);
         Monitor.Pulse(_lock);
     }
 }
 public void Show(ToastData data)
 {
     if (_view.CheckAccess())
     {
         _viewModel.NewNotification(data);
     }
     else
     {
         _view.Dispatcher.BeginInvoke(new Action<ToastData>(Show), DispatcherPriority.Background, data);
     }
 }
        private void ToastRun()
        {
            while (true)
            {
                lock (_lock)
                {
                    if (_toastQueue.IsEmpty)
                    {
                        if (CurrentToast != null)
                        {
                            CurrentToast = null;
                            OnDeactivate();
                        }

                        Monitor.Wait(_lock);
                    }
                }

                ToastData toastData;
                if (_toastQueue.TryDequeue(out toastData))
                {
                    OnActivate();
                    CurrentToast = toastData;
                    Thread.Sleep(Math.Max(toastData.DisplayTime, 2000));
                }
            }
        }