You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now consider a handler where a potentially long, async operation is executed. It would be nice to pass a cancellation token to such operation. Something like this:
Is this currently possible with some enricher? Or, do I need custom middleware? I checked the default HandlerInvocationMiddleware (relevant call pasted below) and it does not pass the cancellation token to the handler.
using (var cts = new CancellationTokenSource())
{
var token = cts.Token;
await client.SubscribeAsync<BasicMessage>(async msg =>
{
await LongOperationAsync(msg.Prop, token);
}, null, token);
};
Because if you'd expect it to be provided via (msg, cancellationToken) then what would be the source of the token? The one (I suppose) you would like to obtain would come from your code anyways.
Hello. Hopefully this is just a simple question.
As a quick background, the canonical example for receiving messages is:
Now consider a handler where a potentially long, async operation is executed. It would be nice to pass a cancellation token to such operation. Something like this:
Is this currently possible with some enricher? Or, do I need custom middleware? I checked the default HandlerInvocationMiddleware (relevant call pasted below) and it does not pass the cancellation token to the handler.
The text was updated successfully, but these errors were encountered: