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 7172063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:32:22+00:00 2026-05-28T15:32:22+00:00

Let’s say I have a Timer control with interval set to 20ms. Inside this

  • 0

Let’s say I have a Timer control with interval set to 20ms. Inside this control I am doing some operation that takes 100ms to complete. So once it is doing that operation, will Timer control execute again without waiting for that operation to finish? Or until that operation is not finished, Timer will not execute again?

EDIT
I am using System.Timers.Timer() in a separate thread in console application. I have edited my question after discussing with Andrew below.

  • 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-28T15:32:23+00:00Added an answer on May 28, 2026 at 3:32 pm

    System.Timers.Timer both runs and raises events on a ‘random’, thread pool thread. The callbacks and the timer ticks will run concurrently, meaning you would have overlapping execution of these events in your situation where the interval is less than the time the method takes to terminate.

    Even though this behavior is different from that which I posted about below, you still don’t want to do this. The result will be that the thread pool will eventually become exhausted. It is also probably not your desired functionality.

    A solution would be to code it such that concurrent execution is not possible.

    1. Test some static field to see if an existing iteration is running, and cancel the ‘new’ instance if so. Testing/setting such a field should be done through a memory barrier.
    2. Stop the timer upon entering the event, run the code, and then start it again after. If you wish, you can adjust the interval based on how long it took to execute.
    3. Do not do simple locking to block concurrent executions until former ones are done; that will just go back to the problem I described with the Windows Forms Timer (minus the UI lockup)

    Previous Answer

    This was the old answer I posted when I thought you were speaking of the Timer in System.Windows.Forms and using it in a Windows Forms program. Because that is not the case, the information below does not apply to you. But I leave it here in case it helps someone else.

    Because the Timer control inside the System.Windows.Forms namespace runs on the UI thread, as does its callback, your tick events will pile up, waiting for currently executing operations to complete. You UI will also be locked in the duration.

    Therefore, you do not want to do this. Your program will lock up.

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

Sidebar

Related Questions

Let's say that I have a set of relations that looks like this: relations
Let's say that I have classes like this: public class Parent { public int
Let's say i have this block of code, <div id=id1> This is some text
Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say there is a graph and some set of functions like: create-node ::
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.

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.