Click here to Skip to main content
12,815,019 members (40,312 online)
Click here to Skip to main content
Add your own
alternative version

Stats

135.6K views
2.6K downloads
97 bookmarked
Posted 2 Feb 2007

Timer surprises, and how to avoid them

, 2 Feb 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
A simple app demonstrates unexpected behavior of .NET timers and Thread.Sleep(); native multimedia timers come to the rescue.
 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Luc Pattyn
Software Developer (Senior) Perceler
Belgium Belgium
I am an engineer with a background in electronics, software and mathematics.

I develop technical software, both for embedded systems and for desktop equipment. This includes operating systems, communication software, local networks, image processing, machine control, automation, etc.

I have been using all kinds of microcontrollers and microprocessors (Intel 4004/8080/8051/80386/Pentium, Motorola 680x/680x0/ColdFire/PowerPC, Microchip PIC, Altera NIOS, and many more), lots of programming languages (all relevant assemblers, Fortran, Basic, C, Java, C#, and many more), and different operating systems (both proprietary and commercial).

For desktop applications and general development tools I have been using both UNIX systems and Mac/MacOS for many years, but I have switched to x86-based PCs with Windows, Visual Studio and the .NET Framework several years ago.

I specialize in:
- cross-platform development (making software that runs on diverse hardware/OS combinations)
- instruction set simulation
- improving software performance, i.e. making sure the software runs the job at hand in as short a time as possible on the given hardware. This entails algorithm selection, implementation design, accurate measurements, code optimisation, and sometimes implementing virtual machines, applying SIMD technology (such as MMX/SSE), and more.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralMy vote of 5 Pin
Akram El Assas29-Feb-12 6:18
memberAkram El Assas29-Feb-12 6:18 
GeneralRe: My vote of 5 Pin
Luc Pattyn29-Feb-12 6:38
mvpLuc Pattyn29-Feb-12 6:38 
GeneralMy vote of 5 Pin
Erik Rude19-Dec-11 7:22
memberErik Rude19-Dec-11 7:22 
It is very good. Would be great with a StopWatch comparison, but knowing all this is going to be helpful. Thanks.
GeneralMy vote of 5 Pin
hmasd21-May-11 9:48
memberhmasd21-May-11 9:48 
GeneralMy vote of 5 Pin
JOAT-MON8-Jan-11 13:44
memberJOAT-MON8-Jan-11 13:44 
GeneralGood work Pin
Ekvilibrium5-Apr-10 10:34
memberEkvilibrium5-Apr-10 10:34 
GeneralRe: Good work Pin
Luc Pattyn5-Apr-10 13:08
mvpLuc Pattyn5-Apr-10 13:08 
Generallook at System::Threading::timers Pin
robinson oliva17-Jun-09 7:41
memberrobinson oliva17-Jun-09 7:41 
AnswerRe: look at System::Threading::timers Pin
Luc Pattyn17-Jun-09 8:37
mvpLuc Pattyn17-Jun-09 8:37 
GeneralRe: look at System::Threading::timers Pin
robinson oliva17-Jun-09 9:47
memberrobinson oliva17-Jun-09 9:47 
AnswerRe: look at System::Threading::timers Pin
Luc Pattyn17-Jun-09 9:56
mvpLuc Pattyn17-Jun-09 9:56 
GeneralRe: look at System::Threading::timers Pin
robinson oliva17-Jun-09 10:04
memberrobinson oliva17-Jun-09 10:04 
GeneralRe: look at System::Threading::timers Pin
general.failure13-Jul-09 2:40
membergeneral.failure13-Jul-09 2:40 
AnswerRe: look at System::Threading::timers Pin
Luc Pattyn13-Jul-09 2:49
mvpLuc Pattyn13-Jul-09 2:49 
GeneralRe: look at System::Threading::timers Pin
general.failure13-Jul-09 9:09
membergeneral.failure13-Jul-09 9:09 
GeneralMy vote of 2 Pin
Ali Tarhini16-Jan-09 23:22
memberAli Tarhini16-Jan-09 23:22 
GeneralRe: My vote of 2 PinPopular
total_havoc29-Jan-09 13:09
membertotal_havoc29-Jan-09 13:09 
GeneralRe: My vote of 2 Pin
Xmen 23-Mar-09 18:57
member Xmen 23-Mar-09 18:57 
GeneralThread.Sleep halts the program longer than i request Pin
Ali_quaidian7-Dec-08 8:22
memberAli_quaidian7-Dec-08 8:22 
AnswerRe: Thread.Sleep halts the program longer than i request Pin
Luc Pattyn7-Dec-08 9:04
mvpLuc Pattyn7-Dec-08 9:04 
GeneralThis is the best article never read .... really Pin
Giacomo Veneri6-Dec-08 9:57
memberGiacomo Veneri6-Dec-08 9:57 
GeneralRe: This is the best article never read .... really Pin
Luc Pattyn6-Dec-08 10:05
mvpLuc Pattyn6-Dec-08 10:05 
GeneralTypo Pin
Pete O'Hanlon17-Oct-07 1:47
memberPete O'Hanlon17-Oct-07 1:47 
AnswerRe: Typo Pin
Luc Pattyn17-Oct-07 2:16
memberLuc Pattyn17-Oct-07 2:16 
GeneralRe: Typo Pin
Pete O'Hanlon17-Oct-07 3:11
memberPete O'Hanlon17-Oct-07 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 2 Feb 2007
Article Copyright 2007 by Luc Pattyn
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid