What is the reason for “while(true) { Thread.Sleep }”?

前端 未结 7 1812
自闭症患者
自闭症患者 2021-02-09 05:43

I sometimes encounter code in the following form:

while (true) {
  //do something
  Thread.Sleep(1000);
}

I was wondering if this is considered

7条回答
  •  说谎
    说谎 (楼主)
    2021-02-09 06:02

    There are better ways to keep the Azure Service and exit when needed.

    Refer:

    1. http://magnusmartensson.com/howto-wait-in-a-workerrole-using-system-timers-timer-and-system-threading-eventwaithandle-over-system-threading-thread-sleep
    2. http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/azure-worker-role-exiting-safely/

提交回复
热议问题