-
Nov 20th, 2016, 08:17 PM
#1
Thread Starter
New Member
[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
-
Nov 21st, 2016, 02:58 AM
#2
Re: Basketball Timer
All you would need is to inherit the Label class and then add a Timer and any required logic.
-
Nov 22nd, 2016, 02:35 PM
#3
Hyperactive Member
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
-
Nov 24th, 2016, 02:26 AM
#4
Thread Starter
New Member
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.
-
Nov 24th, 2016, 11:47 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|