public static void UpdateTask ( this TaskQueueManager taskQueueManager, TaskProcessorJob job, MFTaskState state, string progressData = "" ) { // Sanity. if (null == taskQueueManager) { throw new ArgumentNullException(nameof(taskQueueManager)); } if (null == job) { throw new ArgumentNullException(nameof(job)); } // Use the default UpdateTask implementation. taskQueueManager.UpdateTask(job.AppTaskId, state, progressData); }
/// <summary> /// Marks the <paramref name="job"/> to have the completed state of <paramref name="targetState"/>. /// </summary> /// <param name="job">The job to update.</param> /// <param name="targetState">The final completed state.</param> /// <param name="exception">The exception, if the state is failed.</param> protected void CompleteJob ( AppTasks.ITaskProcessingJob <BackgroundOperationTaskDirective> job, MFTaskState targetState, Exception exception = null ) { // Skip nulls. if (null == job) { return; } // Update the task. try { // Build up the task information with new data. var taskInformation = new TaskInformation(job.GetStatus()?.Data); taskInformation.CurrentTaskState = targetState; taskInformation.Completed = DateTime.Now; taskInformation.LastActivity = DateTime.Now; if (exception != null) { taskInformation.StatusDetails = exception.Message; } // Update the task information. job.Update(taskInformation); } catch { #if DEBUG throw; #endif } }