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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:54:02+00:00 2026-05-13T10:54:02+00:00

Im creating a game … I want to add a counter as a clock

  • 0

Im creating a game … I want to add a counter as a clock exactly the same as the Time counter in Microsoft solitair game & i want later when the game is over the time stop and the time reached to be saved in a variable what ever but i want to use this number to generate a scores table.

thanx in advance….
I will post the whole game when its 100% done so you guys can Enjoy 🙂

  • 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-13T10:54:02+00:00Added an answer on May 13, 2026 at 10:54 am

    You could use a Stopwatch object.

    Here’s a link on how to use it:
    http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx

    To start the stopwatch do this:

    Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
    

    To stop:

    stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed; // gets elapsed time
    

    To show time that’s elapsed:

    // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                ts.Hours, ts.Minutes, ts.Seconds,
                ts.Milliseconds / 10);
    

    Now you can display the ‘elapsedtime’ string in your strip.

    EDIT:

    To see moving time, put following in Button click handler to start time:

        // global variable
            string timeelepse = string.empty; 
       // in button click handler
        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
    
    
                sw.Start();
    
                System.Threading.Thread t = new System.Threading.Thread(delegate()
                {
                    while (true)
                    {
                    TimeSpan ts = sw.Elapsed;
    
                    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                    ts.Hours, ts.Minutes, ts.Seconds,
                    ts.Milliseconds / 10);
    
                    timeelepse = elapsedTime;
    
                      UpdateLabel();
                    }
                });
                t.Start();
    

    Now add these two functions & delegate to your forms class:

    public delegate void doupdate();
            public void UpdateLabel()
            {
                doupdate db = new doupdate(DoUpdateLabel);
                this.Invoke(db);
            }
    
            public void DoUpdateLabel()
            {
                toolStripStatusLabel1.Text = timeelepse;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a new Facebook developer. I'm creating a game and want to include a
I am creating a game using cocos2d. Now what I want is I need
I'm creating a game currently and I want to limit one account per person.
Ok, so in creating a game in my spare time, I've been completely stuck
I'm planning on creating a game that contains a landscape with objects on it.
I'm interested in creating a game that uses fractal maps for more realistic geography.
I am creating a matching game for Android, and when the user gets a
I am creating a C++ SDL game engine, and it is relevant to know
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
I'm creating game mario like in win32 GDI . I've implemented the new loop

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.