DispatchTimer - Prevent the tick event to be triggered if the previous tick is still running

后端 未结 4 1929
被撕碎了的回忆
被撕碎了的回忆 2021-01-19 13:56

In a Silverlight app, I have a block of code that has to run every 500ms. I am planning o use a DispatcherTimer to achieve this (see code below).

Dispatcher         


        
4条回答
  •  伪装坚强ぢ
    2021-01-19 14:28

    In order make the event run successfull without getting a call from your DispatcherTimer again with in the previous tick completes stop the dispatcher timer after entering in to dt_Tick event and at the end of the tick event call the start again which will initializes the IsEnabled of DispatcherTimer again to true.

提交回复
热议问题