How to set the timer to the role of a worker?

How to create a worker role in Azure using a timer?

+3
source share
1 answer

If you create a new worker role, the template code creates the Run () method for you. In this Run () method, you will see the easiest way to create a timer:

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

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

+4
source

Source: https://habr.com/ru/post/1778464/


All Articles