public void RemoveItem() { if (_selectedItem == null) { return; } JobCollection.Remove(_selectedItem); NotifyOfPropertyChange(() => JobCollection); SelectedItem = null; }
private void QueueCompleted(object sender, QueueCompletedEventArgs args) { _queueProcessor.QueueCompleted -= QueueCompleted; _queueProcessor.QueueProgressChanged -= QueueProgressChanged; _queueProcessor.QueueStarted -= QueueStarted; Execute.OnUIThread(() => { var finishedList = JobCollection.Where(encodeInfo => encodeInfo.NextStep == EncodingStep.Done).ToList(); foreach (var encodeInfo in finishedList) { JobCollection.Remove(encodeInfo); } }); Close(); }
/// <summary> /// Finishes queued job. /// </summary> /// <param name="job">Job instance to finish.</param> private static void FinishJob(Job job) { Type type = typeof(JobManager); // Use _queuedJobs collection to remove the job from the queue. FieldInfo queuedFI = type.GetField("_queuedJobs", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); // Use private method of JobManager class to finish the job. MethodInfo finishJobMI = type.GetMethod("FinishJob", BindingFlags.Static | BindingFlags.NonPublic); if (queuedFI != null && finishJobMI != null) { JobCollection queuedJobs = queuedFI.GetValue(null) as JobCollection; if (queuedJobs != null && finishJobMI != null) { // Remove the job from queuedJobs collection. queuedJobs.Remove(job); queuedFI.SetValue(null, queuedJobs); // Move the job to finishedJobs collection. finishJobMI.Invoke(null, new object[] { job }); } } }