none
System.Threading.Timer callback gets called after Change(Timeout.Infinite,Timeout.Infinite)

    Question

  • Hello everyone,

     

    It would seem the System.Threading.Timer callback may be called once even after Change(Timeout.Infinite,Timeout.Infinite).

    Anyone had the same problem?

     

    Thanks

     

    Tuesday, June 10, 2008 3:32 PM

Answers

  • Hi, lmira

     

    Unlike the System.Windows.Forms.Timer whose Tick event is called by the UI thread, the callback of the System.Threading.Timer is executed on worker threads. So there are chances that when you call the Change method to stop the Threading.Timer, one or even several callbacks are already queued so they will eventually be executed.

     

     

    Best Regards

    Chunsheng Tang

     

    Thursday, June 12, 2008 2:43 AM
    Moderator

All replies

  • Hi, lmira

     

    Unlike the System.Windows.Forms.Timer whose Tick event is called by the UI thread, the callback of the System.Threading.Timer is executed on worker threads. So there are chances that when you call the Change method to stop the Threading.Timer, one or even several callbacks are already queued so they will eventually be executed.

     

     

    Best Regards

    Chunsheng Tang

     

    Thursday, June 12, 2008 2:43 AM
    Moderator
  • Hi,

    I have a windows service in which i have used a timer class for scheduling the task ... the time interval of the Timer.Change is 24 hours, 

    Now the problem is that when I stop the  service the queued timer task is executed, How to kill that queued task. 

    please send me some code... and from where I can kill the same manually.

    Thanks

    Wednesday, February 12, 2014 2:27 PM