public void SetException(Exception exception) { Task taskIfDebuggingEnabled = this.GetTaskIfDebuggingEnabled(); if (taskIfDebuggingEnabled != null) { if (DebuggerSupport.LoggingOn) { DebuggerSupport.TraceOperationCompletion(CausalityTraceLevel.Required, taskIfDebuggingEnabled, AsyncStatus.Error); } } AsyncMethodBuilderCore.ThrowAsync(exception, m_synchronizationContext); NotifySynchronizationContextOfCompletion(); }
/// <summary>Completes the method builder successfully.</summary> public void SetResult() { Task taskIfDebuggingEnabled = this.GetTaskIfDebuggingEnabled(); if (taskIfDebuggingEnabled != null) { if (DebuggerSupport.LoggingOn) { DebuggerSupport.TraceOperationCompletion(CausalityTraceLevel.Required, taskIfDebuggingEnabled, AsyncStatus.Completed); } DebuggerSupport.RemoveFromActiveTasks(taskIfDebuggingEnabled); } NotifySynchronizationContextOfCompletion(); }
public void SetResult() { var task = m_task; if (task == null) { m_task = s_cachedCompleted; } else { if (DebuggerSupport.LoggingOn) { DebuggerSupport.TraceOperationCompletion(CausalityTraceLevel.Required, task, AsyncStatus.Completed); } DebuggerSupport.RemoveFromActiveTasks(task); if (!task.TrySetResult(default(VoidTaskResult))) { throw new InvalidOperationException(SR.TaskT_TransitionToFinal_AlreadyCompleted); } } }
public static void TraceOperationCompletedError(Task task) { DebuggerSupport.TraceOperationCompletion(CausalityTraceLevel.Required, task, AsyncStatus.Error); }