开发者

How to set timer on worker role?

开发者 https://www.devze.com 2023-01-28 02:55 出处:网络
How to cr开发者_运维问答eate a Worker role in Azure using timer?If you create a new worker role, the template code generates a Run() method for you. In that Run() method, you\'ll see the easiest way t

How to cr开发者_运维问答eate a Worker role in Azure using timer?


If you create a new worker role, the template code generates a Run() method for you. In that Run() method, you'll see the easiest way to create a timer:

while (true)
{
    Thread.Sleep(10000);
    Trace.WriteLine("Working", "Information");
}

So in this example, the thread sleeps for 10 seconds, then wakes up and emits a log statement. You can change the time interval to be anything you want, and you then call whatever custom code you have after Thread.Sleep() returns.

0

精彩评论

暂无评论...
验证码 换一张
取 消