CancellationTokenSource构造函数延迟参数和CancelAfter方法有什么区别
What's the difference between CancellationTokenSource constructor delay parameter and CancelAfter Method
鉴于这两种方法
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
行为上有什么真正的区别吗?
唯一的信息是在 MS docs 上,但由于引用
而不清楚
Subsequent calls to CancelAfter will reset the delay for this CancellationTokenSource, if it has not been canceled already.
所以我猜它会重置它,但它是否有任何其他操作?
According to the source,什么都没有。他们都分配给 m_timer
鉴于这两种方法
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
var cts = new CancellationTokenSource();
cts.CancelAfter(TimeSpan.FromMinutes(1));
行为上有什么真正的区别吗?
唯一的信息是在 MS docs 上,但由于引用
而不清楚Subsequent calls to CancelAfter will reset the delay for this CancellationTokenSource, if it has not been canceled already.
所以我猜它会重置它,但它是否有任何其他操作?
According to the source,什么都没有。他们都分配给 m_timer