Esempio n. 1
0
 public void NotifyBackgroundJobFinished(int token)
 {
     Dispatcher.Invoke(() =>
     {
         lock (lockObject)
         {
             JobProgressViewModel job;
             if (jobList.TryGetValue(token, out job))
             {
                 jobList.Remove(token);
                 if (CurrentJob == job)
                 {
                     job = null;
                     foreach (JobPriority priority in Enum.GetValues(typeof(JobPriority)).Cast <JobPriority>().Reverse())
                     {
                         var nextJob = jobList.LastOrDefault(x => x.Value.Priority == priority).Value;
                         if (nextJob != null)
                         {
                             job = nextJob;
                         }
                     }
                     CurrentJob = job;
                 }
             }
         }
     });
 }
Esempio n. 2
0
 public int NotifyBackgroundJobStarted(string message, JobPriority priority, int count = -1)
 {
     return(Dispatcher.Invoke(() =>
     {
         lock (lockObject)
         {
             var job = new JobProgressViewModel(ServiceProvider, message, priority, count);
             jobList.Add(++currentToken, job);
             if (CurrentJob == null || CurrentJob.Priority <= priority)
             {
                 CurrentJob = job;
             }
             return currentToken;
         }
     }));
 }