internal YieldAndNotifyAwaiter(INotifyCompletion baseAwaiter, AsyncManualResetEvent yieldingSignal, AsyncManualResetEvent resumingSignal) { Requires.NotNull(baseAwaiter, nameof(baseAwaiter)); this.baseAwaiter = baseAwaiter; this.yieldingSignal = yieldingSignal; this.resumingSignal = resumingSignal; }
} // proc ProcessMessageLoop /// <summary>Run the message loop in the current context/thread.</summary> /// <param name="onCompletion"></param> public void ProcessMessageLoop(INotifyCompletion onCompletion) { using (var cancellationTokenSource = new CancellationTokenSource()) { onCompletion.OnCompleted(cancellationTokenSource.Cancel); ProcessMessageLoop(cancellationTokenSource.Token); } } // proc ProcessMessageLoop
/// <summary> /// Schedules the state machine to proceed to the next action when the specified awaiter completes. /// </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 TrueAwaitOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine) { try { Action completionAction = m_coreState.GetCompletionAction(this, stateMachine); awaiter.OnCompleted(completionAction); } catch (Exception ex) { AsyncMethodBuilderCore.ThrowAsync(ex); } }
/// <summary> /// Schedules the state machine to proceed to the next action when the specified awaiter completes. /// </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 TrueAwaitOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine) { m_builder.TrueAwaitOnCompleted(awaiter, stateMachine); }
/// <summary> /// Forces an awaitable to yield, setting signals after the continuation has been pended and when the continuation has begun execution. /// </summary> /// <param name="baseAwaiter">The awaiter to extend.</param> /// <param name="yieldingSignal">The signal to set after the continuation has been pended.</param> /// <param name="resumingSignal">The signal to set when the continuation has been invoked.</param> /// <returns>A new awaitable.</returns> internal static YieldAndNotifyAwaitable YieldAndNotify(this INotifyCompletion baseAwaiter, AsyncManualResetEvent yieldingSignal = null, AsyncManualResetEvent resumingSignal = null) { Requires.NotNull(baseAwaiter, nameof(baseAwaiter)); return(new YieldAndNotifyAwaitable(baseAwaiter, yieldingSignal, resumingSignal)); }
private void AwaitOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine) { awaiter.OnCompleted(() => stateMachine.MoveNext()); }
public static void NoWarning(this INotifyCompletion task) { }
public Awaiter(Func<object, bool> isCompleted, Func<object, object> getResult, INotifyCompletion inner) { _isCompleted = isCompleted; _getResult = getResult; _inner = inner; }
public TotemInternalAwaitable(Func<object, bool> isCompleted, Func<object, object> getResult, INotifyCompletion inner) { _awaiter = new Awaiter(isCompleted, getResult, inner); }
void AwaitUnsafeOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine) { base.AwaitUnsafeOnCompleted(awaiter, stateMachine); }
// AsyncMethodBuilder public void AwaitOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine) { awaiter.OnCompleted(stateMachine.MoveNext); }