public BackgroundTask SubmitBackgroundJob(string taskName, string uiText = null, string finishedUiText = null)
        {
            lock (lockSubmitJob)
            {
                if (uiText != null && finishedUiText == null || uiText == null && finishedUiText != null)
                {
                    throw new Exception("Internal error: Cannot submit background job only specifying start or end text without the specifying both.");
                }

                BackgroundTask bt = new BackgroundTask(taskName, ++nextJobID, uiText, finishedUiText);
                backgroundJobs.TryAdd(bt.jobID, bt);
                if (uiText != null)
                {
                    updateTextDelegate(uiText);
                }

                showIndicatorDelegate();
                Log.Information("Submitted a background task to engine: " + taskName);
                return(bt);
            }
        }
예제 #2
0
        public void SubmitJobCompletion(BackgroundTask task)
        {
            if (backgroundJobs.TryRemove(task.jobID, out BackgroundTask t))
            {
                Log.Information("Completed a background task: " + t.taskName);
                if (backgroundJobs.Count <= 0)
                {
                    hideIndicatorDelegate();
                    if (task.finishedUiText != null)
                    {
                        updateTextDelegate(task.finishedUiText);
                    }

                    else
                    {
                        backgroundJobs.First().Value.active = true;
                        updateTextDelegate(backgroundJobs.First().Value.uiText);
                    }
                }
            }
        }
 public void SubmitJobCompletion(BackgroundTask task)
 {
     lock (lockReleaseJob)
     {
         if (backgroundJobs.TryRemove(task.jobID, out BackgroundTask t))
         {
             Log.Information("Completed a background task: " + t.taskName);
             if (!backgroundJobs.Any())
             {
                 hideIndicatorDelegate();
                 if (task.finishedUiText != null)
                 {
                     updateTextDelegate(task.finishedUiText);
                 }
                 ActiveJob = null;
             }
             else
             {
                 ActiveJob = backgroundJobs.First().Value;
                 updateTextDelegate(ActiveJob.uiText);
             }
         }
     }
 }