I have async method that takes CancellationToken as parameter so that it can be passed to another method called later. I would like to call that inner method with CancellationToken that cancels after 10s or if "parent" CancellationToken is canceled manually.
I have method A with CancellationToken parameter. I have method B with CancellationToken parameter called from method A.
I would like to call method B with token that is canceled after 10s or when "original" token that gets passed to method A gets cancelled.
I know I can use CancellationTokenSource(TimeSpan.FromSeconds(10)) to get token that canceled after 10s and pass it to method B from A. But I don't know how to cancel method B if token from method A's parameters gets canceled.
CancellationTokensfor this.CancellationToken.Registeron the first token to schedule the cancellation on the second one usingCancellationTokenSource.CancelAfter?