Results 1 to 5 of 5

Thread: [RESOLVED] Basketball Timer

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2016
    Posts
    5

    Resolved [RESOLVED] Basketball Timer

    Hi Guys,


    I'm planning to create a basketball timer control (just a like a new control in toolbox) that show the remaining time?

    Even link to read for me to create this control.


    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,350

    Re: Basketball Timer

    All you would need is to inherit the Label class and then add a Timer and any required logic.

  3. #3
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    Re: Basketball Timer

    Here is a video that covers this a little better for you. I didn't make this video but it covers making your own controls quite well.
    https://www.youtube.com/watch?v=rY3nDOaD878

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2016
    Posts
    5

    Re: Basketball Timer

    Thanks this is a big help. I have this code which is an infinite loop.

    Code:
    int counter = 0;
    while (counter == 0)
    {
        RemainingTime -= 1;
        Thread.Sleep(1000);
    }
    So when RemainingTime is equal to 0, It it will give a notification that it has already expired.

    One more question, I found out the Thread.Sleep(1000) is not accurate for timer. Kindly help me what should I use to make my timer accurate even for a CPU that is redlined at 100%, the timer should not lose, nor gain time.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: Basketball Timer

    I moved the thread to C#, as that appears to be the language you are using.

    There is nothing you can do to ensure absolute accuracy on a Windows system. That's the nature of the operating system, because threads can be preempted. Theoretically, you could do this by elevating the thread privilege, but you really shouldn't do that. Threads with elevated privileges run ahead of everything else, which would mean that your application could block EVERYTHING else, including the OS itself, which could do some really bad things.

    Without that, though, you are sharing hardware with other running programs (at least the OS, if nothing else), and that's just the nature of the environment. If you want to be absolutely accurate you need to have dedicated hardware for that, as nothing else will do.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width