How to fire timer.Elapsed event immediately

前端 未结 10 1221
独厮守ぢ
独厮守ぢ 2020-12-10 00:17

I\'m using the System.Timers.Timer class to create a timer with an Timer.Elapsed event. The thing is the Timer.Elapsed event is fired

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 00:44

    I'm not a pro so take this with a pinch of salt but it works. I created a function and instead of putting my code into the timer sub I put it into the function. Then I merely called the function when I wanted it (in my case on page load) and then the timer code would fire at the interval times and simply call the function in the timer sub code.

提交回复
热议问题