コード例 #1
0
 public void NewNotification(ToastData data)
 {
     lock (_lock)
     {
         _toastQueue.Enqueue(data);
         Monitor.Pulse(_lock);
     }
 }
コード例 #2
0
 public void Show(ToastData data)
 {
     if (_view.CheckAccess())
     {
         _viewModel.NewNotification(data);
     }
     else
     {
         _view.Dispatcher.BeginInvoke(new Action<ToastData>(Show), DispatcherPriority.Background, data);
     }
 }
コード例 #3
0
        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));
                }
            }
        }