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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:50:30+00:00 2026-06-15T15:50:30+00:00

I have a game in C# and I need to allow tournament mode in

  • 0

I have a game in C# and I need to allow tournament mode in which each round will be of 2 minutes. How can I display the time from 0:00 up till 2:00 on the form?

I have this in a constructor:

        Timer timer = new Timer();
        timer.Interval = 1000;
        timer.Tick += new EventHandler(Timer_Tick);
        timer.Start();

And this is the Event Handler

    void Timer_Tick(object sender, EventArgs e)
    {
        this.textBox1.Text = DateTime.Now.ToLongTimeString();
    }

but I don’t know how I can begin the time from 0:00 instread of the current time.. I tried creating a DateTime instance but when I do myDateTime.ToString(); in the event handler, it just remains 0:00.

I tried searching but I can’t find anything related.
Thanks a lot !

  • 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-06-15T15:50:31+00:00Added an answer on June 15, 2026 at 3:50 pm

    You need a member variable that is in scope for both the timer initialization and the Timer_Tick event handler.

    class Something
    {
        DateTime _myDateTime;
        Timer _timer;
    
        public Something()
        {
            _timer = new Timer();
            _timer.Interval = 1000;
            _timer.Tick += Timer_Tick;
    
            _myDateTime = DateTime.Now;
            _timer.Start();
    
        }
    
        void Timer_Tick(object sender, EventArgs e)
        {
            var diff = DateTime.Now.Subtract(_myDateTime);
            this.textBox1.Text = diff.ToString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am working on voxel based game engine, in which i need to have
I'm building a real time game, mostly chat based, and I need to have
I am starting a game project which will allow characters to hide in dark
I have two objects in a game, which for this purpose can be considered
For the needs of my game I need to have 2D sound. That means,
I have a game application released at the Facebook platform. I need to set
I am writing a game in Java, and need to have mouse interaction. I
I'm developing a game. I want to have game entities each have their own
In my 2D game I need textures that may be arbitrarily large, can be
I'm writing an online game which allows a user to progress from one puzzle

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.