コード例 #1
0
        public static Task ConsumeAsync <T>(
            this IReadableChannel <T> channel,
            Action <T> handle,
            Func <Task> onCompletedAsync             = null,
            Func <Exception, Task> onTerminatedAsync = null)
        {
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
            return(channel.ConsumeAsync(async x => handle(x)));

#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        }
コード例 #2
0
        private async Task ProcessAsync()
        {
            try
            {
                await _connection.ConsumeAsync(HandleReceivedAsync).ConfigureAwait(false);

                _log.Trace("Receiving completed");
            }
            catch (Exception ex)
            {
                _log.Trace("Receiving failed: {0}", ex.FormatTypeAndMessage());
                throw;
            }
        }
コード例 #3
0
 public static Task ConsumeAsync <T>(
     this IReadableChannel <T> channel,
     Action <T> handle,
     CancellationToken cancellationToken      = default,
     Func <Task> onCompletedAsync             = null,
     Func <Exception, Task> onTerminatedAsync = null)
 {
     return(channel.ConsumeAsync(
                x =>
     {
         handle(x);
         return CompletedTask;
     },
                cancellationToken,
                onCompletedAsync,
                onTerminatedAsync));
 }
コード例 #4
0
 private async Task ProcessMessagesAsync()
 {
     try
     {
         await _transport.ConsumeAsync(HandleIncomingFrameAsync, CancellationToken).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         _buffer.Out.TryTerminate(ex);
         _buffer.In.ConsumeBufferedItems(_ => { });
         throw;
     }
     finally
     {
         await _buffer.In.Completion.ConfigureAwait(false);
     }
 }
コード例 #5
0
 public static Task PipeAsync <T>(
     this IReadableChannel <T> readableChannel,
     IObserver <T> observer,
     CancellationToken cancellationToken = default(CancellationToken),
     bool sendCompete   = false,
     bool sendException = false)
 {
     return(readableChannel.ConsumeAsync(obj => observer.OnNext(obj), cancellationToken, () =>
     {
         if (sendCompete)
         {
             observer.OnCompleted();
         }
         return TaskHelper.CompletedTask;
     }, exception =>
     {
         if (sendException)
         {
             observer.OnError(exception);
         }
         return TaskHelper.FromException(exception);
     }));
 }
コード例 #6
0
 public static Task DisposeRemainingItemsAsync <T>(
     this IReadableChannel <T> channel) where T : IDisposable
 {
     return(channel.ConsumeAsync(x => x.Dispose()));
 }
コード例 #7
0
 private async Task ProcessAsync()
 {
     await _transport.ConsumeAsync(HandleIncomingFrameAsync, CancellationToken).ConfigureAwait(false);
 }