public QueueTask GetNextJobForProcessing() { if (this.queue.Count > 0) { QueueTask task = this.queue.FirstOrDefault(q => q.Status == QueueItemStatus.Waiting); if (task != null && task.TaskType == QueueTaskType.EncodeTask) { task.TaskToken = this.hardwareResourceManager.GetToken(task.Task); } return(task); } return(null); }
// Start is called before the first frame update void OnEnable() { var queueManager_Instance = QueueManager.Instance; QueueTask queueTask1 = new QueueTask(CreateCube, null); queueManager_Instance.m_QueueDic.Add(queueTask1);//添加一个任务进去 QueueTask queueTask2 = new QueueTask(RotateCube, null); queueManager_Instance.m_QueueDic.Add(queueTask2);//添加一个任务进去 queueManager_Instance.StartQueue();//启动队列任务 }
public void execute_tasks_ERROR_HANDLE_ATTEMPS_1_worker_10_Iterations() { int itterationCount = 10; const string queueName = "execute_tasks_ERROR_HANDLE_ATTEMPS_1_worker_10_Iterations"; int workerscount = 1; var executer = new MockBehaviorErorrTaskExecution(); var queue = QueueFactory.CreateQueueHandleFailed(workerscount, executer, 3, queueName); for (int i = 1; i <= itterationCount; i++) { queue.AddTask(QueueTask.Create(0, i.ToString())); } WaitTast(10000); Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString()); }
public ITask Parallelize(System.Func <bool> poller, float timeout = -1f, string name = "") { IEnumerableAction action = EnumerableAction.Create(() => WaitOnCondition(poller), 1, name); QueueTask task = new QueueTask(this, action) { RequestedTimeout = timeout }; lock (_lock) { _tasks.Enqueue(task); } return(task); }
/// <summary> /// Edit a job /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void MnuEditClick(object sender, EventArgs e) { if (list_queue.SelectedIndices != null && list_queue.SelectedIndices.Count != 0) { lock (queue) { lock (list_queue) { QueueTask index = list_queue.SelectedItems[0].Tag as QueueTask; mainWindow.RecievingJob(index); queue.QueueManager.Remove(index); RedrawQueue(); } } } }
/// <summary> /// Setup the logging. /// </summary> /// <param name="encodeQueueTask"> /// The encode QueueTask. /// </param> protected void SetupLogging(QueueTask encodeQueueTask) { ShutdownFileWriter(); string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.GetInstanceCount)); string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", GeneralUtilities.GetInstanceCount)); try { string query = QueryGeneratorUtility.GenerateQuery(new EncodeTask(encodeQueueTask.Task)); this.logBuffer = new StringBuilder(); this.logBuffer.AppendLine(String.Format("CLI Query: {0}", query)); this.logBuffer.AppendLine(String.Format("User Query: {0}", encodeQueueTask.CustomQuery)); this.logBuffer.AppendLine(); // Clear the current Encode Logs) if (File.Exists(logFile)) { File.Delete(logFile); } if (File.Exists(logFile2)) { File.Delete(logFile2); } this.fileWriter = new StreamWriter(logFile) { AutoFlush = true }; this.fileWriter.WriteLine(GeneralUtilities.CreateCliLogHeader()); this.fileWriter.WriteLine(String.Format("CLI Query: {0}", query)); this.fileWriter.WriteLine(String.Format("User Query: {0}", encodeQueueTask.CustomQuery)); this.fileWriter.WriteLine(); } catch (Exception) { if (this.fileWriter != null) { this.fileWriter.Close(); this.fileWriter.Dispose(); } throw; } }
/// <summary> /// Verify the Encode Destination path exists and if not, create it. /// </summary> /// <param name="task"> /// The task. /// </param> /// <exception cref="Exception"> /// If the creation fails, an exception is thrown. /// </exception> protected void VerifyEncodeDestinationPath(QueueTask task) { // Make sure the path exists, attempt to create it if it doesn't try { string path = Directory.GetParent(task.Task.Destination).ToString(); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } catch (Exception exc) { throw new GeneralApplicationException( "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc); } }
public void execute_tasks_4_worker_100_Iterations() { int itterationCount = 100; const string queueName = "execute_tasks_4_worker_100_Iterations"; int workerscount = 4; var executer = new MockBehaviorTaskExecution(); var queue = QueueFactory.CreateQueue(workerscount, executer, queueName); for (int i = 1; i <= itterationCount; i++) { queue.AddTask(QueueTask.Create(0, i.ToString())); } WaitTast(100); Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString()); }
public DispatchQueue() { // true means that the door is "open" // false means that the door is "closed" // calling Set() will set the door to "open". If the door is already open, this does nothing. // WaitOne() will block until the door is set to "open" by someone else (on another thread) moreStuffReceived = new ManualResetEvent(false); Thread t = new Thread(() => { using (source = new CancellationTokenSource()) // TODO: this could cause threading issues if something else is using this token when it is disposed { cancellationToken = source.Token; while (!done) { QueueTask task = null; lock (tasks) { if (tasks.Count > 0) { task = tasks.Dequeue(); } else if (!done) { moreStuffReceived.WaitOne(); } } if (task != null) { try { task(); } catch (Exception e) { UnityEngine.Debug.LogError(e); } } } moreStuffReceived.Dispose(); source.Cancel(); } }); t.Start(); }
/// <summary> /// Run through all the jobs on the queue. /// </summary> private void ProcessNextJob() { QueueTask job = this.GetNextJobForProcessing(); if (job != null) { this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job)); this.EncodeService.Start(job); } else { // No more jobs to process, so unsubscribe the event this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted; // Fire the event to tell connected services. this.OnQueueCompleted(new QueueCompletedEventArgs(false)); } }
/// <summary> /// Verify the Encode Destination path exists and if not, create it. /// </summary> /// <param name="task"> /// The task. /// </param> /// <exception cref="Exception"> /// If the creation fails, an exception is thrown. /// </exception> protected void VerifyEncodeDestinationPath(QueueTask task) { // Make sure the path exists, attempt to create it if it doesn't string path = Directory.GetParent(task.Destination).ToString(); if (!Directory.Exists(path)) { try { Directory.CreateDirectory(path); } catch (Exception) { throw new Exception( "Unable to create directory for the encoded output. Please verify the drive and path is correct."); } } }
/// <summary> /// Encode and play a sample /// </summary> public void Play() { try { this.IsEncoding = true; if (File.Exists(this.CurrentlyPlaying)) { File.Delete(this.CurrentlyPlaying); } } catch (Exception) { this.IsEncoding = false; this.errorService.ShowMessageBox("Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } if (this.Task == null || string.IsNullOrEmpty(Task.Source)) { this.errorService.ShowMessageBox("You must first scan a source and setup your encode before creating a perview.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } EncodeTask encodeTask = new EncodeTask(this.Task) { PreviewDuration = this.Duration, PreviewStartAt = this.StartAt, PointToPointMode = PointToPointMode.Preview }; this.CurrentlyPlaying = encodeTask.Destination.Replace(".m", "_sample.m"); // Setup the encode task as a preview encode encodeTask.IsPreviewEncode = true; encodeTask.PreviewEncodeStartAt = this.StartAt.ToString(CultureInfo.InvariantCulture); encodeTask.PreviewEncodeDuration = this.Duration; QueueTask task = new QueueTask { Task = encodeTask, }; ThreadPool.QueueUserWorkItem(this.CreatePreview, task); }
public (Staging, QueueTask, string) CaptureStaging(string Owner, int Time, params int[] perfer) { if (Time >= 365 || Time <= 0) { return(null, null, "时间只能在(0, 365]之间"); } Staging staging = null; if (GetAllStaging().Any(s => s.Owner == Owner && perfer.Contains(s.StagingId) && IsStagingInUse(s.StagingId))) { return(null, null, "你已经占了期望的Staging了,请换个Staging"); } if (perfer.Length == 0 && GetAllStaging().Any(s => s.Owner == Owner && IsStagingInUse(s.StagingId))) { return(null, null, "你已经占了任意一台Staging,如需其他Staging,请指定Staging"); } if (perfer.Length > 0) { staging = GetStaging(perfer.FirstOrDefault(id => !IsStagingInUse(id))); } else { staging = GetAllStaging().FirstOrDefault(s => !IsStagingInUse(s.StagingId)); } if (staging != null) { staging.Owner = Owner; staging.StartTime = DateTime.Today; staging.Timeleft = Time; _save(); return(staging, null, string.Empty); } var task = new QueueTask() { Owner = Owner, PreferStaging = perfer, Timeleft = Time }; AllStaging.QueueTasks.Enqueue(task); _save(); return(null, task, string.Empty); }
public void ExecuteTasks_on_1_Worker_Test() { int itterationCount = 10; int executedTasksCount = 1; const string queueName = "ExecuteTasks_on_1_Worker_Test"; int workerscount = 1; var queue = QueueFactory.CreateQueue(workerscount, new MockTaskExecuter(), queueName); queue.TaskExecutionEvents.SuccessExecuteTaskEvent += delegate(ITaskStore store, QueueTask task) { executedTasksCount++; }; for (int i = 0; i < itterationCount; i++) { queue.AddTask(QueueTask.Create(0, i.ToString())); } Assert.AreEqual(itterationCount, executedTasksCount); }
/// <summary> /// Start an Encode /// </summary> public void StartEncode() { // Santiy Checking. if (this.ScannedSource == null || this.CurrentTask == null) { this.errorService.ShowMessageBox("You must first scan a source.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(this.CurrentTask.Destination)) { this.errorService.ShowMessageBox("The Destination field was empty.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (this.queueProcessor.IsProcessing) { this.errorService.ShowMessageBox("HandBrake is already encoding.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (File.Exists(this.CurrentTask.Destination)) { MessageBoxResult result = this.errorService.ShowMessageBox("The current file already exists, do you wish to overwrite it?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.No) { return; } } // Create the Queue Task and Start Processing QueueTask task = new QueueTask(null) { Destination = this.CurrentTask.Destination, Task = this.CurrentTask, Query = QueryGeneratorUtility.GenerateQuery(this.CurrentTask), CustomQuery = false }; this.queueProcessor.QueueManager.Add(task); this.queueProcessor.Start(); this.IsEncoding = true; }
public void Test_Queue_QM_On_NumberCalculateExecuter_with_2_Workers() { int itterationCount = 10; int executedTasksCount = 1; const string queueName = "Test_Queue_QM_On_NumberCalculateExecuter_with_2_Workers"; var queue = QueueFactory.CreateQueue(2, new MockTaskExecuter(), queueName); queue.TaskExecutionEvents.SuccessExecuteTaskEvent += delegate(ITaskStore store, QueueTask task) { executedTasksCount++; }; QueueManager.Kernal.RegistrateQueue(queue); for (int i = 0; i < itterationCount; i++) { QueueManager.Kernal[queueName].AddTask(QueueTask.Create(0, i.ToString())); } Assert.AreEqual(itterationCount, executedTasksCount); }
/// <summary> /// Create the Preview. /// </summary> /// <param name="state"> /// The state. /// </param> private void CreatePreview(object state) { // Make sure we are not already encoding and if we are then display an error. if (encodeQueue.IsEncoding) { MessageBox.Show( this, "Handbrake is already encoding a video!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } QueueTask task = new QueueTask((string)state); encodeQueue.Start(task, false); }
/// <summary> /// Get the first job on the queue for processing. /// This also removes the job from the Queue and sets the LastProcessedJob /// </summary> /// <returns> /// An encode Job object. /// </returns> public QueueTask GetNextJobForProcessing() { if (this.queue.Count > 0) { QueueTask job = this.queue.FirstOrDefault(q => q.Status == QueueItemStatus.Waiting); if (job != null) { job.Status = QueueItemStatus.InProgress; this.LastProcessedJob = job; InvokeQueueChanged(EventArgs.Empty); } this.BackupQueue(string.Empty); return(job); } this.BackupQueue(string.Empty); return(null); }
private void ProcessNextJob() { QueueTask job = this.GetNextJobForProcessing(); if (job != null) { if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(job.Task.Destination, this.userSettingService.GetUserSetting <long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel))) { this.logService.LogMessage(Resources.PauseOnLowDiskspace); job.Status = QueueItemStatus.Waiting; this.Pause(); this.BackupQueue(string.Empty); return; // Don't start the next job. } job.Status = QueueItemStatus.InProgress; job.Statistics.StartTime = DateTime.Now; this.LastProcessedJob = job; this.IsProcessing = true; this.InvokeQueueChanged(EventArgs.Empty); this.InvokeJobProcessingStarted(new QueueProgressEventArgs(job)); if (!Directory.Exists(Path.GetDirectoryName(job.Task.Destination))) { this.EncodeServiceEncodeCompleted(null, new EncodeCompletedEventArgs(false, null, "Destination Directory Missing", null, null, null, 0)); this.BackupQueue(string.Empty); return; } this.EncodeService.Start(job.Task, job.Configuration, job.SelectedPresetKey); this.BackupQueue(string.Empty); } else { // No more jobs to process, so unsubscribe the event this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted; this.BackupQueue(string.Empty); // Fire the event to tell connected services. this.OnQueueCompleted(new QueueCompletedEventArgs(false)); } }
public void execute_task_4_worker_self_tread__100_Iterations() { int itterationCount = 100; const string queueName = "execute_task_4_worker_self_tread__100_Iterations"; int workerscount = 4; var executer = new MockBehaviorTaskExecution(); var queue = QueueFactory.CreateQueue(workerscount, executer, queueName); for (int i = 1; i <= itterationCount; i++) { queue.AddTaskAsync(QueueTask.Create(0, i.ToString())).Wait(); var a = rnd.Next(1, 31); if (a % 2 == 0) { WaitTast(2); } } Assert.AreEqual(itterationCount.ToString(), executer.ExecutionTaskCount.ToString()); }
public void AddBreakPoint() { lock (QueueLock) { int foundIndex = -1; QueueTask firstWaitingJob = this.queue.FirstOrDefault(t => t.Status == QueueItemStatus.Waiting); if (firstWaitingJob != null) { foundIndex = this.queue.IndexOf(firstWaitingJob); } if (foundIndex != -1) { this.queue.Insert(foundIndex, new QueueTask(QueueTaskType.Breakpoint)); } this.IsProcessing = false; } }
/// <summary> /// Remove a Job from the queue /// </summary> /// <param name="task"> /// The Job to remove from the queue /// </param> public void RemoveJob(QueueTask task) { if (task.Status == QueueItemStatus.InProgress) { MessageBoxResult result = this.errorService.ShowMessageBox( "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.queueProcessor.QueueManager.Remove(task); } } else { this.queueProcessor.QueueManager.Remove(task); } this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.QueueManager.Count); }
/// <summary> /// Says if the param 'other' is contained in any _newBuildsAnchors /// /// and if the element on the queue was added after the route was created /// </summary> private bool IsOnQueue(TheRoute theRoute, QueueTask queueTask, string personID = "") { for (int i = 0; i < queueTask.Elements.Count; i++) { DateTime date1 = queueTask.Elements[i].DateTime1; DateTime date2 = theRoute.DateTime1; int result = DateTime.Compare(date1, date2); //can be called here bz a person when call the Queues to check in goes trhu all of them queueTask.Elements[i].CheckPersonIn(personID); //if they intersect and //the queue element was created later than the route then need to reroute if (queueTask.Contains(theRoute.AreaRect, i) && result > 0) { _currenTime = queueTask.Elements[i].DateTime1; return(true); } } return(false); }
private void HandleBreakPoint(QueueTask task) { lock (QueueLock) { if (this.activeJobs.Count != 0) { return; // Wait for jobs to finish! } this.StopJobPolling(); // Remove the Breakpoint Execute.OnUIThread(() => this.queue.Remove(task)); this.IsProcessing = false; this.IsPaused = false; // Setting the flag will allow or prevent the when done actions to be processed. this.InvokeQueueCompleted(new QueueCompletedEventArgs(false)); } }
public void EditJob(QueueTask task) { MessageBoxResult result = this.errorService.ShowMessageBox( Resources.QueueViewModel_EditConfrimation, "Modify Job?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } // Remove the job if it is not already encoding. Let the user decide if they want to cancel or not. this.RemoveJob(task); // Pass a copy of the job back to the Main Screen IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.EditQueueJob(task); }
/// <summary> /// Edit this Job /// </summary> /// <param name="task"> /// The task. /// </param> public void EditJob(QueueTask task) { MessageBoxResult result = this.errorService.ShowMessageBox( "Are you sure you wish to edit this job? It will be removed from the queue and sent to the main window.", "Modify Job?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } // Remove the job if it is not already encoding. Let the user decide if they want to cancel or not. this.RemoveJob(task); // Pass a copy of the job back to the Main Screen IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.EditQueueJob(new EncodeTask(task.Task)); }
/// <summary> /// Add the current task to the queue. /// </summary> public void AddToQueue() { if (this.ScannedSource == null || string.IsNullOrEmpty(this.ScannedSource.ScanPath) || this.ScannedSource.Titles.Count == 0) { this.errorService.ShowMessageBox("You must first scan a source and setup your job before adding to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } QueueTask task = new QueueTask { Task = this.CurrentTask, Query = QueryGeneratorUtility.GenerateQuery(this.CurrentTask) }; this.queueProcessor.QueueManager.Add(task); if (!this.IsEncoding) { this.ProgramStatusLabel = string.Format("{0} Encodes Pending", this.queueProcessor.QueueManager.Count); } }
public void RemoveJob(object queueTask) { QueueTask task = queueTask as QueueTask; if (task == null) { return; } bool removed = false; int index = this.QueueTasks.IndexOf(task); if (task.Status == QueueItemStatus.InProgress) { MessageBoxResult result = this.errorService.ShowMessageBox( Resources.QueueViewModel_JobCurrentlyRunningWarning, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { this.queueProcessor.Stop(); this.queueProcessor.Remove(task); removed = true; } } else { this.queueProcessor.Remove(task); removed = true; } if (this.QueueTasks.Any() && removed) { this.SelectedTask = index > 1 ? this.QueueTasks[index - 1] : this.QueueTasks.FirstOrDefault(); } }
public static QueueTask GenerateFullQuery(frmMain mainWindow) { // Create the CLI Query string query = string.Empty; query += SourceQuery(mainWindow, mainWindow.drop_mode.SelectedIndex, 0, null); query += DestinationQuery(mainWindow, QueryEncodeMode.Standard); query += GenerateTabbedComponentsQuery(mainWindow, true, QueryPictureSettingsMode.UserInterfaceSettings, 0, 0); // Create the Queue Task and setup the EncodeTask model object. Preset preset = null; if (mainWindow.treeView_presets.SelectedNode != null) { preset = mainWindow.treeView_presets.SelectedNode.Tag as Preset; } bool isCustom = true; if (preset != null && preset.IsBuildIn) { isCustom = false; } EncodeTask task = CreateEncodeTaskObject(mainWindow); QueueTask queueTask = new QueueTask(query) { Source = task.Source, Destination = task.Destination, Title = mainWindow.GetTitle(), CustomQuery = (mainWindow.rtf_query.Text != string.Empty) || isCustom, Task = task, Query = query, }; return(queueTask); }
/// <summary> /// The scan completed. /// </summary> /// <param name="job"> /// The job. /// </param> /// <param name="instance"> /// The instance. /// </param> private void ScanCompleted(QueueTask job, IHandBrakeInstance instance) { // Get an EncodeJob object for the Interop Library EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job); // Start the Encode instance.StartEncode(encodeJob); // Fire the Encode Started Event this.InvokeEncodeStarted(EventArgs.Empty); // Set the Process Priority switch (job.Configuration.ProcessPriority) { case "Realtime": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; break; case "High": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; break; case "Above Normal": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal; break; case "Normal": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; break; case "Low": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle; break; default: Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal; break; } }
/// <summary> /// Reset the job state to waiting. /// </summary> /// <param name="task"> /// The task. /// </param> public void RetryJob(QueueTask task) { task.Status = QueueItemStatus.Waiting; this.queueProcessor.BackupQueue(null); this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); }
/// <summary> /// Initializes a new instance of the <see cref="QueueProgressEventArgs"/> class. /// </summary> /// <param name="newJob"> /// The new job. /// </param> public QueueProgressEventArgs(QueueTask newJob) { this.NewJob = newJob; }
/// <summary> /// The equals. /// </summary> /// <param name="other"> /// The other. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> protected bool Equals(QueueTask other) { return Equals(this.ScannedSourcePath, other.ScannedSourcePath) && Equals(this.Task, other.Task) && this.status == other.status; }
/// <summary> /// Remove a job from the Queue. /// This method is Thread Safe /// </summary> /// <param name="job"> /// The job. /// </param> public void Remove(QueueTask job) { lock (QueueLock) { this.queue.Remove(job); this.InvokeQueueChanged(EventArgs.Empty); } }
/// <summary> /// Reset a Queued Item from Error or Completed to Waiting /// </summary> /// <param name="job"> /// The job. /// </param> public void ResetJobStatusToWaiting(QueueTask job) { if (job.Status != QueueItemStatus.Error && job.Status != QueueItemStatus.Completed) { throw new GeneralApplicationException( "Job Error", "Unable to reset job status as it is not in an Error or Completed state", null); } job.Status = QueueItemStatus.Waiting; }
/// <summary> /// Edit this Job /// </summary> /// <param name="task"> /// The task. /// </param> public void EditJob(QueueTask task) { MessageBoxResult result = this.errorService.ShowMessageBox( Resources.QueueViewModel_EditConfrimation, "Modify Job?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result != MessageBoxResult.Yes) { return; } // Remove the job if it is not already encoding. Let the user decide if they want to cancel or not. this.RemoveJob(task); // Pass a copy of the job back to the Main Screen IMainViewModel mvm = IoC.Get<IMainViewModel>(); mvm.EditQueueJob(new EncodeTask(task.Task)); }