Example #1
0
        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();
        }
Example #2
0
        /// <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();
        }
Example #3
0
        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);
                }
            }
        }
Example #4
0
 public static void TraceOperationCompletedError(Task task)
 {
     DebuggerSupport.TraceOperationCompletion(CausalityTraceLevel.Required, task, AsyncStatus.Error);
 }