/// <summary> /// Schedules the state machine to proceed to the next action when the specified awaiter completes. This method can be /// called from partially trusted code. /// </summary> /// <param name="awaiter">The awaiter.</param> /// <param name="stateMachine">The state machine.</param> /// <typeparam name="TAwaiter">The type of the awaiter.</typeparam> /// <typeparam name="TStateMachine">The type of the state machine.</typeparam> public void AwaitUnsafeOnCompleted <TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { try { Action completionAction = m_coreState.GetCompletionAction(this, stateMachine); awaiter.UnsafeOnCompleted(completionAction); } catch (Exception ex) { AsyncMethodBuilderCore.ThrowAsync(ex); } }
/// <summary> /// Schedules the specified state machine to be pushed forward when the specified awaiter completes. /// </summary> /// <typeparam name="TAwaiter">Specifies the type of the awaiter.</typeparam> /// <typeparam name="TStateMachine">Specifies the type of the state machine.</typeparam> /// <param name="awaiter">The awaiter.</param> /// <param name="stateMachine">The state machine.</param> public void AwaitUnsafeOnCompleted <TAwaiter, TStateMachine>( ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine { try { awaiter.UnsafeOnCompleted(GetMoveNextDelegate(ref stateMachine)); } catch (Exception e) { AsyncMethodBuilderCore.ThrowAsync(e, targetContext: null); } }
public void SetException(Exception exception) { AsyncMethodBuilderCore.ThrowAsync(exception); }