Alternatives to Thread.Sleep()

后端 未结 11 1278
清歌不尽
清歌不尽 2020-11-27 03:48

Every N minutes we want to run through a list of tasks. So we\'ve created a task executor with a

do { DoWork(); }while(!stopRequested)

No

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 04:28

    The three options that I can think of off the top of my head are :

    • System.Threading.Timer (More...)
    • Monitor.Wait (More...)
    • System.Timers.Timer (More...)

    but I am sure as many will mention - Thread.Sleep() isn't all that bad.

提交回复
热议问题