This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Client | |
{ | |
public TimeSpan Timeout { get; } | |
public Client(TimeSpan timeout) | |
{ | |
this.Timeout = timeout; | |
} | |
public async Task SendAsync(CancellationToken cancellationToken = default) | |
{ | |
// Create concatenated new CancellationTokenSource | |
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); | |
cts.CancelAfter(Timeout); | |
await SendCoreAsync(cts.Token); | |
} | |
// snip... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment