Given these two approaches
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
Is there any real difference in behaviour?
The only slight of information is on MS docs but it's not clear since quoting
Subsequent calls to CancelAfter will reset the delay for this CancellationTokenSource, if it has not been canceled already.
So I guess it resets it but does it have any other action regardles?
According to the source, nothing. They both assign to m_timer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With