src/Orleans.Core/Async/AsyncSerialExecutor.cs
/// <summary>
/// Executes the next scheduled function.
/// </summary>
/// <returns>A <see cref="Task"/> representing the operation.</returns>
Executes the next scheduled function.
Executes the next scheduled function .
private async Task ExecuteNext()
        {
            while (!actions.IsEmpty)
            {
                bool gotLock = false;
                try
                {
                    if (!(gotLock = locker.TryGetLock()))
                    {
                        return;
                    }
                    while (!actions.IsEmpty)
                    {
                        Tuple<TaskCompletionSource<TResult>, Func<Task<TResult>>> actionTuple;
                        if (actions.TryDequeue(out actionTuple))
                        {
                            try
                            {
                                TResult result = await actionTuple.Item2();
                                actionTuple.Item1.TrySetResult(result);
                            }
                            catch (Exception exc)
                            {
                                actionTuple.Item1.TrySetException(exc);
                            }
                        }
                    }
                }
                finally
                {
                    if (gotLock)
                        locker.ReleaseLock();
                }
            }
        }
private async Task ExecuteNext ( ) { while ( ! actions . IsEmpty ) { bool gotLock = false ; try { if ( ! ( gotLock = locker . TryGetLock ( ) ) ) { return ; } while ( ! actions . IsEmpty ) { Tuple < TaskCompletionSource < TResult > , Func < Task < TResult > > > actionTuple ; if ( actions . TryDequeue ( out actionTuple ) ) { try { TResult result = await actionTuple . Item2 ( ) ; actionTuple . Item1 . TrySetResult ( result ) ; } catch ( Exception exc ) { actionTuple . Item1 . TrySetException ( exc ) ; } } } } finally { if ( gotLock ) locker . ReleaseLock ( ) ; } } }
Executes the next scheduled function.
Executes the next scheduled function .
A  representing the operation.
A representing the operation .