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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:15:50+00:00 2026-05-28T02:15:50+00:00

I am trying to have one timer which will do things every 5 seconds

  • 0

I am trying to have one timer which will do things every 5 seconds or by user specified time interval.

Now, I want to have a function which will count down in 10 milliseconds interval until tick of first timer. I have played around and found a simple way of doing this by doing count of 1/10 of first timers tick interval but when counting the number doesn’t represent anything.

How to do such count down?

This is how I have at this time, but I want to change it:

    private void tmrClickInterval_Tick(object sender, EventArgs e)
    {
        if (nudPlusMinus.Value == 0) tmrClickInterval.Interval = int.Parse(nudClickInterval.Value.ToString());
        else tmrClickInterval.Interval = random.Next(int.Parse(nudClickInterval.Value.ToString()) - int.Parse(nudPlusMinus.Value.ToString()), int.Parse(nudClickInterval.Value.ToString()) + int.Parse(nudPlusMinus.Value.ToString()));

        if (tmrClickInterval.Interval / 10 == 0) tmrNextClick.Interval = 1;
        else tmrNextClick.Interval = tmrClickInterval.Interval / 10;
        tmrNextClick.Start();
        content++;
        nextClick = tmrClickInterval.Interval;
        label1.Text = content.ToString();
    }

    private void tmrNextClick_Tick(object sender, EventArgs e)
    {
        if (nextClick <= 0) tmrNextClick.Stop();
        else
        {
            nextClick = nextClick - (tmrClickInterval.Interval / 10);
            lblNextClickCount.Text = (nextClick / 100).ToString();
        }
    }
  • 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-28T02:15:51+00:00Added an answer on May 28, 2026 at 2:15 am

    First of all I am not sure of exactly what you are trying to do, also at 10 msec intervals you are pushing the minimum resolution of a timer. See this SO question. That being said you can try using the Diagnostics.Stopwatch Class to time the interval between your Tick events. Something like this:

    private void tmrClickInterval_Tick(object sender, EventArgs e)
        {
            stopWatch.Stop();
            stopWatch.Reset();         
            stopWatch.Start();
            tmrNextClick.Start();
            content++;
            label1.Text = content.ToString();
        }
    
        private void tmrNextClick_Tick(object sender, EventArgs e)
        {
            nextClick = (((tmrClickInterval.Interval) - stopWatch.ElapsedMilliseconds) / 10) * 10;
            if (!(nextClick < 0))
            {
                lblNextClickCount.Text = nextClick.ToString();
            }
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes one of which inherits from the other. Im trying to
I am trying to have one one layer, and center images within. I.E., if
I am trying to learn more about regular expressions I have one below that
I'm trying to get rid of floats in my functions. I have one function
I am trying to make a Postgres PHP backup script. I have downloaded one
I'm trying to find out where this function comes from. Any one have any
I have been trying to get this one section of my UI to immediatly
Ok, so i have been trying to put everyone one of my classes in
I have a question related to this one : I'm trying to attach an
I have a site I'm trying to build and I've hit one little snag

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.