Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6579173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:51:55+00:00 2026-05-25T15:51:55+00:00

I have an Azure Worker Role with n (currently n = 2) instances. Each

  • 0

I have an Azure Worker Role with n (currently n = 2) instances. Each of these instances has a System.Timers.Timer on its main thread that executes every 20 seconds, spawning some work processes. When the role instances boot up initially, they synchronize themselves via internal endpoints so that the timers start at the same time (this works).

Over the course of even a day, these two timers with the same interval tend to wander – one will end up starting several seconds before it used to, and the other may go the same direction or, worse, the other.

My run method is basically the following:

public override void Run()
{
    while (true) 
    {               
        GC.KeepAlive(this.LogTimer); // make sure garbage collection never touches the timer                                            
    }
}

Questions:

  1. What might be causing this?
  2. Would adding a Thread.Sleep(sleeptimeinMS) call to the while(true){} loop improve
    this by preventing the main thread from being busy all the time (to
    allow the timer thread to be somehow more free to do its duty?)?
  3. Is the right answer that I should try to resync the roles to some
    external clock periodically?
  4. Any radically different ways to implement this?

Thanks in advance for your time,

Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:51:55+00:00Added an answer on May 25, 2026 at 3:51 pm

    A System.Timers.Timer is not 100% accurate, it is limited by the thread scheduling in the OS. It makes good sense that two separate servers each running a Timer, eventually will get out of synch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I already have a hosted service deployment which has 2 worker role instances, I
Suppose I have an Azure role with three instances running. I ask Azure to
I have a class library shared between an Azure Worker Role and a ASP.NET
We have a requirement to read an excel sheet from the Azure worker role.
I have deployed a Worker Role to an Azure instance with remote access enabled.
I, Here is my situation. I have a worker role in my Azure who
I have an Azure Worker Role set up to get information from a few
Hi I have created a new azure project with a worker role and have
I have created my first app for azure. It's has an MVC3 web role
We have a Web Role that we are hosting in Windows Azure that uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.