blankensteiner commented on PR #207:
URL: https://github.com/apache/pulsar-dotpulsar/pull/207#issuecomment-2016832571

   TryReceive can be written as an extension method. I was think something like:
   
   ```
   public static bool TryReceive<TMessage>(this IReceive<IMessage<TMessage>> 
receiver, out IMessage<TMessage>? message)
   {
       message = null;
       var cts = new CancellationTokenSource();
       var messageTask = receiver.Receive(cts.Token);
       cts.Cancel();
       if (messageTask.IsCompletedSuccessfully)
       {
           message = messageTask.Result;
           return true;
       }
   
       return false;
   }
   ```
   
   I haven't tested this, but something like that would do the trick.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to