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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:56:25+00:00 2026-05-18T09:56:25+00:00

I want to have a counter that counts down from 60 seconds to 0.

  • 0

I want to have a counter that counts down from 60 seconds to 0. I want the user to see the number of seconds on the UI. To accomplish this, I thought I would display a basic TextBlock like such:

<StackPanel>
  <TextBlock Text=" " />
  <TextBlock Text=" seconds remaining" />
</StackPanel>

I then was thinking of using a Timer. The only timer I’m aware of though is the DispatcherTimer. However, that doesn’t show how much time has elapsed or how much time is remaining. Because of this, I have nothing to bind to.

private DispatcherTimer myTimer = new DispatcherTimer();    
public MainPage() {
  myTimer.Interval = new TimeSpan(0, 0, 60);
  myTimer.Tick += new EventHandler(myTimer_Tick);
  myTimer.Start();
}

I’m not sure how to do this. A co-worker told me that I shouldn’t even do this because it will slow down the UI. But the users really want it. Can somebody tell me:

1) Will it really bog down the UI that much?
2) If not, how do I do this?

Thanks!

  • 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-18T09:56:26+00:00Added an answer on May 18, 2026 at 9:56 am
    1. Yes. It will slow it down by an imperceivable amount. Frankly, it would be absolutely ridiculous to be worried about this.

    2. On every tick, decrement a property. Bind your UI to that property. Alternatively, simply invalidate a property on every tick, and have the property getter calculate the time remaining.

    Option 1

    myTimer.Interval = TimeSpan.FromSeconds(1);
    myTimer.Tick += delegate
    {
        this.SecondsRemaining = this.SecondsRemaining - 1;
    
        if (this.SecondsRemaining == 0)
        {
            myTimer.Dispose();
        }
    };
    this.SecondsRemaining = 60;
    myTimer.Start();
    
    ...
    
    // assumes your class implements INotifyPropertyChanged and you have a helper method to raise OnPropertyChanged
    public int SecondsRemaining
    {
        get { return this.secondsRemaining; }
        private set
        {
            this.secondsRemaining = value;
            this.OnPropertyChanged(() => this.SecondsRemaining);
        }
    }
    

    Option 2

    myTimer.Interval = TimeSpan.FromSeconds(1);
    myTimer.Tick += delegate
    {
        this.OnPropertyChanged("TimeRemaining");
    
        if (this.TimeRemaining <= 0)
        {
            myTimer.Dispose();
        }
    };
    this.endTime = DateTime.UtcNow.AddMinutes(1);
    myTimer.Start();
    
    public int TimeRemaining
    {
        get { return (endTime - DateTime.UtcNow).TotalSeconds; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a peice of code that counts from 0 to a specified number
I have a counter snippet and right now it's set so it counts down
I have a form that I want to close after 5 seconds if no
I want to get specific counters for processes that I have process id's for.
I have a counter in a JPanel in my java applet. I want the
I have a UITextView and I want have two buttons. When the user taps
I want to have a form on my page take user input, a URL
A need some help, I have a TextBlock that contains a string like this
I have a database table called users This table has two columns (that are
Edit: PIC 16F684 Okay, I have a simple 3 LED binary clock that counts

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.