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

  • Home
  • SEARCH
  • 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 6220059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:53:31+00:00 2026-05-24T07:53:31+00:00

During debugging I can see that after Timer.Stop() or Timer.Enabled = false commands are

  • 0

During debugging I can see that after Timer.Stop() or Timer.Enabled = false commands are executed, Timer is still running (Timer.Enabled = true). How is that possible?

  • 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-24T07:53:31+00:00Added an answer on May 24, 2026 at 7:53 am

    This is possible when you stop the timer on a worker thread. For example:

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        Timer timer1;
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            timer1 = new Timer();
            timer1.Interval = 3000;
            timer1.Start();
            var t = new System.Threading.Thread(stopTimer);
            t.Start();
        }
        private void stopTimer() {
            timer1.Enabled = false;
            System.Diagnostics.Debug.WriteLine(timer1.Enabled.ToString());
        }
    }
    

    Output:
    True

    The timer must be stopped by the UI thread, the class takes care of it automatically. Quite similar to Control.BeginInvoke(). There’s an explicit race, the Tick event handler can run after you stopped it. This can also happen on the UI thread if the very first timer you create is created on a worker thread. A splash screen for example. That’s not healthy, you ought to fix that.

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

Sidebar

Related Questions

When navigating to previous calls/events during debugging with IntelliTrace, I can't see a snapshot
Is there any watch window to see variable value in XCode during debugging? Can
EDIT: I had made a mistake during the debugging session that lead me to
For some reason, it seems that stopping at a breakpoint during debugging will kill
I have a small problem during debugging my App in VS 2010 RC when
During development (and for debugging) it is very useful to run a Java class'
During many, sometimes inundating, debugging sessions using DDD, I stumble upon loops. And I
What's the easiest way to print a stacktrace from a debugging printout? Often during
During a typical day programming, I implement functions in a way that I would
My problem is, I'm using a TreeView in a UserControl. While debugging, I can

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.