Task event or action on cancel token requested

后端 未结 1 1537
离开以前
离开以前 2021-01-19 01:05

This is my code:

public sealed class ProcessingTask : ProcessingObject
{
    private CancellationTokenSource _cancelToken;    
    private int _timeOut = 100         


        
1条回答
  •  天涯浪人
    2021-01-19 01:39

    You're looking for CancellationToken.Register:

    Registers a delegate that will be called when this CancellationToken is canceled.

    Register an action like this:

    _cancelToken.Token.Register(() => DoStuff());
    

    0 讨论(0)
提交回复
热议问题