Why does System.Timer.Timer still fire events when Enabled is set to false?

前端 未结 5 553
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 04:35

I have attempted to create a derived class of Timer that allows for a \'Pause\' latch to be set to keep the worker thread from reactivating the timer. However, Elapsed event

5条回答
  •  一向
    一向 (楼主)
    2021-01-12 05:20

    I would reformat your code:

    // from this
    if (!value) base.Enabled = false;
    
    // to this
    if (!value) 
        base.Enabled = false;
    

    Not only does it read better, you can put a break point on the key line and see if it's being executed

提交回复
热议问题