protected virtual void AddBagToQueue(DisplayTaskBag task)
 {
     lock (this.Lock)
     {
         this.QueuedTasks.Add(task);
         task.Task.State = NotificationState.InQueue;
     }
 }
        protected virtual void LastPreparationsAndVisualizeTask(DisplayTaskBag task)
        {
            var uiManager = HatcherGuide <IUIManager> .Instance;

            uiManager.ExecuteActionOnUIThreadAsynchronously(
                delegate
            {
                var window = HatcherGuide <INotificationWindow> .CreateNewInstance();
                task.WindowVM.ResultObtained += this.WindowVM_ResultObtained;
                window.PrepareAndDisplay(task.WindowVM);
            });
        }
 protected virtual void ProcessPendingQueue()
 {
     lock (this.Lock)
     {
         this.RemoveExpiredTasks();
         this.RecalculateDisplayedTasksPositions();
         DisplayTaskBag nextBagToDisplay = this.DequeueBagAndPrepareItToDisplay();
         while (nextBagToDisplay != null)
         {
             this.RecalculateDisplayedTasksPositions();
             this.LastPreparationsAndVisualizeTask(nextBagToDisplay);
             nextBagToDisplay = this.DequeueBagAndPrepareItToDisplay();
         }
     }
 }
        protected virtual bool DiscardTask(NotificationDisplayTask task, bool onlyIfNonDisplayed)
        {
            DisplayTaskBag bagToRemove = null;

            try
            {
                lock (this.Lock)
                {
                    bagToRemove = this.QueuedTasks.FirstOrDefault(displayTaskBag => displayTaskBag.Task == task);
                    if (bagToRemove != null)
                    {
                        this.QueuedTasks.Remove(bagToRemove);
                        return(true);
                    }
                    //Don't try to remove from main collection if flag is true
                    if (onlyIfNonDisplayed)
                    {
                        return(false);
                    }
                    bagToRemove = this.DisplayedWaitForResultTasks.FirstOrDefault(displayTaskBag => displayTaskBag.Task == task);
                    if (bagToRemove == null)
                    {
                        return(false);
                    }
                    this.DisplayedWaitForResultTasks.Remove(bagToRemove);
                    return(true);
                }
            }
            finally
            {
                if (bagToRemove != null)
                {
                    bagToRemove.WindowVM.IsAlive = false;
                    bagToRemove.Task.State       = NotificationState.Aborted;
                }
            }
        }
예제 #5
0
 protected virtual void LastPreparationsAndVisualizeTask(DisplayTaskBag task)
 {
     var uiManager = HatcherGuide<IUIManager>.Instance;
       uiManager.ExecuteActionOnUIThreadAsynchronously(
     delegate
       {
     var window = HatcherGuide<INotificationWindow>.CreateNewInstance();
     task.WindowVM.ResultObtained += this.WindowVM_ResultObtained;
     window.PrepareAndDisplay(task.WindowVM);
       });
 }
예제 #6
0
 protected virtual void AddBagToQueue(DisplayTaskBag task)
 {
     lock (this.Lock)
       {
     this.QueuedTasks.Add(task);
     task.Task.State = NotificationState.InQueue;
       }
 }