Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What's the difference between CancellationTokenSource constructor delay parameter and CancelAfter Method

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

According to the source, nothing. They both assign to m_timer

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading