private async Task HandleResponseMessageAsync(TResponse msg)
        {
            var header = _protocol.MessageFactory.CreateInvocationMessageReceived();

            if (!_sender.TryWrite(header))
            {
                await _sender.WriteOrDisposeAsync(header, CancellationToken).ConfigureAwait(false);
            }
            Log.Debug("Sent confirmation about received response of type {0}", msg.GetType().Name);
            if (!_responses.TryWrite(msg))
            {
                await _responses.WriteAsync(msg, CancellationToken).ConfigureAwait(false);
            }
            Log.Debug("Consumed response of type {0}", msg.GetType().Name);
        }
Beispiel #2
0
 private static void Produce(BufferedChannel <Message> collection, CancellationToken cancellationToken)
 {
     try
     {
         var message = new Message {
             Content = ""
         };
         while (!cancellationToken.IsCancellationRequested)
         {
             if (collection.TryWrite(message))
             {
                 Interlocked.Add(ref _producedCount, 1);
             }
         }
     }
     finally
     {
         Console.WriteLine("producer finished..");
     }
 }