// Token: 0x06005D16 RID: 23830 RVA: 0x001465B8 File Offset: 0x001447B8 internal void PostBoxInitialization(IAsyncStateMachine stateMachine, AsyncMethodBuilderCore.MoveNextRunner runner, Task builtTask) { if (builtTask != null) { if (AsyncCausalityTracer.LoggingOn) { AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, builtTask.Id, "Async: " + stateMachine.GetType().Name, 0UL); } if (Task.s_asyncDebuggingEnabled) { Task.AddToActiveTasks(builtTask); } } this.m_stateMachine = stateMachine; this.m_stateMachine.SetStateMachine(this.m_stateMachine); runner.m_stateMachine = this.m_stateMachine; }
public void AwaitOnCompleted <TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine { try { AsyncMethodBuilderCore.MoveNextRunner runner = null; Action completionAction = this.m_coreState.GetCompletionAction(AsyncCausalityTracer.LoggingOn ? this.Task : null, ref runner); if (this.m_coreState.m_stateMachine == null) { if (AsyncCausalityTracer.LoggingOn) { AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Task.Id, "Async: " + stateMachine.GetType().Name, 0UL); } this.m_coreState.PostBoxInitialization(stateMachine, runner, null); } awaiter.OnCompleted(completionAction); } catch (Exception exception) { AsyncMethodBuilderCore.ThrowAsync(exception, null); } }
public void SetResult(TResult result) { Task <TResult> task = this.m_task; if (task == null) { this.m_task = this.GetTaskForResult(result); return; } if (AsyncCausalityTracer.LoggingOn) { AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Completed); } if (System.Threading.Tasks.Task.s_asyncDebuggingEnabled) { System.Threading.Tasks.Task.RemoveFromActiveTasks(task.Id); } if (!task.TrySetResult(result)) { throw new InvalidOperationException(Environment.GetResourceString("TaskT_TransitionToFinal_AlreadyCompleted")); } }
public void AwaitUnsafeOnCompleted <TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { try { AsyncMethodBuilderCore.MoveNextRunner runnerToInitialize = (AsyncMethodBuilderCore.MoveNextRunner)null; Action completionAction = this.m_coreState.GetCompletionAction(AsyncCausalityTracer.LoggingOn ? this.Task : (Task)null, ref runnerToInitialize); if (this.m_coreState.m_stateMachine == null) { if (AsyncCausalityTracer.LoggingOn) { AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, this.Task.Id, "Async: " + stateMachine.GetType().Name, 0UL); } this.m_coreState.PostBoxInitialization((IAsyncStateMachine)stateMachine, runnerToInitialize, (Task)null); } awaiter.UnsafeOnCompleted(completionAction); } catch (Exception ex) { // ISSUE: variable of the null type __Null local = null; AsyncMethodBuilderCore.ThrowAsync(ex, (SynchronizationContext)local); } }
/// <summary>Faults the method builder with an exception.</summary> /// <param name="exception">The exception that is the cause of this fault.</param> /// <exception cref="System.ArgumentNullException">The <paramref name="exception"/> argument is null (Nothing in Visual Basic).</exception> /// <exception cref="System.InvalidOperationException">The builder is not initialized.</exception> public void SetException(Exception exception) { if (exception == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.exception); } if (AsyncCausalityTracer.LoggingOn) { AsyncCausalityTracer.TraceOperationCompletion(this.Task, AsyncCausalityStatus.Error); } if (_synchronizationContext != null) { // If we captured a synchronization context, Post the throwing of the exception to it // and decrement its outstanding operation count. try { System.Threading.Tasks.Task.ThrowAsync(exception, targetContext: _synchronizationContext); } finally { NotifySynchronizationContextOfCompletion(); } } else { // Otherwise, queue the exception to be thrown on the ThreadPool. This will // result in a crash unless legacy exception behavior is enabled by a config // file or a CLR host. System.Threading.Tasks.Task.ThrowAsync(exception, targetContext: null); } // The exception was propagated already; we don't need or want to fault the builder, just mark it as completed. _builder.SetResult(); }
public void SetException(Exception exception) { if (exception == null) { throw new ArgumentNullException("exception"); } if (AsyncCausalityTracer.LoggingOn) { AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, this.Task.Id, AsyncCausalityStatus.Error); } if (this.m_synchronizationContext != null) { try { AsyncMethodBuilderCore.ThrowAsync(exception, this.m_synchronizationContext); return; } finally { this.NotifySynchronizationContextOfCompletion(); } } AsyncMethodBuilderCore.ThrowAsync(exception, null); }
internal static void TraceSynchronousWorkCompletion() { AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution); }
internal static void TraceSynchronousWorkStart(Task task) { AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, task.Id, CausalitySynchronousWork.Execution); }
public static void TraceOperationCompletedError(Task task) { AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Error); }
public static void TraceOperationCreation(Task task, string operationName) { AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, task.Id, operationName, 0); }
public static void TraceOperationCompletedError(Task task) { AsyncCausalityTracer.TraceOperationCompletion(task, AsyncCausalityStatus.Error); }
public static void TraceOperationCompletedSuccess(Task task) { AsyncCausalityTracer.TraceOperationCompletion(task, AsyncCausalityStatus.Completed); }
public static void TraceOperationCreation(Task task, string operationName) { AsyncCausalityTracer.TraceOperationCreation(task, operationName); }