You can pass a CancellationToken
to Publish
. If canceled, an OperationCanceledException
will be thrown. If you want to use a timeout, you can create a CancellationTokenSource
with a timeout.
using var source = new CancellationTokenSource(TimeSpan.FromSeconds(30));
await bus.Publish(message, source.Token);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…