Ejemplo n.º 1
0
            internal YieldAndNotifyAwaiter(INotifyCompletion baseAwaiter, AsyncManualResetEvent yieldingSignal, AsyncManualResetEvent resumingSignal)
            {
                Requires.NotNull(baseAwaiter, nameof(baseAwaiter));

                this.baseAwaiter    = baseAwaiter;
                this.yieldingSignal = yieldingSignal;
                this.resumingSignal = resumingSignal;
            }
Ejemplo n.º 2
0
        }         // 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
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
        /// <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());
 }
Ejemplo n.º 7
0
 public static void NoWarning(this INotifyCompletion task)
 {
 }
Ejemplo n.º 8
0
 public Awaiter(Func<object, bool> isCompleted, Func<object, object> getResult, INotifyCompletion inner)
 {
     _isCompleted = isCompleted;
     _getResult = getResult;
     _inner = inner;
 }
Ejemplo n.º 9
0
 public TotemInternalAwaitable(Func<object, bool> isCompleted, Func<object, object> getResult, INotifyCompletion inner)
 {
     _awaiter = new Awaiter(isCompleted, getResult, inner);
 }
Ejemplo n.º 10
0
 void AwaitUnsafeOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine)
 {
     base.AwaitUnsafeOnCompleted(awaiter, stateMachine);
 }
Ejemplo n.º 11
0
 // AsyncMethodBuilder
 public void AwaitOnCompleted(INotifyCompletion awaiter, IAsyncStateMachine stateMachine)
 {
     awaiter.OnCompleted(stateMachine.MoveNext);
 }