Click here to Skip to main content
15,917,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Windows Mobile 5 / C++ simple question / begging Pin
Polity4h15-Jan-07 13:22
Polity4h15-Jan-07 13:22 
GeneralRe: Windows Mobile 5 / C++ simple question / begging Pin
Rajesh R Subramanian15-Jan-07 18:09
professionalRajesh R Subramanian15-Jan-07 18:09 
GeneralRe: Windows Mobile 5 / C++ simple question / begging Pin
Iain Clarke, Warrior Programmer15-Jan-07 22:31
Iain Clarke, Warrior Programmer15-Jan-07 22:31 
GeneralRe: Windows Mobile 5 / C++ simple question / begging [modified] Pin
Rajesh R Subramanian15-Jan-07 22:37
professionalRajesh R Subramanian15-Jan-07 22:37 
GeneralRe: Windows Mobile 5 / C++ simple question / begging Pin
Iain Clarke, Warrior Programmer16-Jan-07 3:55
Iain Clarke, Warrior Programmer16-Jan-07 3:55 
QuestionCreate DLL Single Document Application Pin
sdancer7515-Jan-07 5:25
sdancer7515-Jan-07 5:25 
QuestionGoing Loopy Pin
Waldermort15-Jan-07 4:52
Waldermort15-Jan-07 4:52 
AnswerRe: Going Loopy Pin
Roger Stoltz15-Jan-07 5:34
Roger Stoltz15-Jan-07 5:34 
WalderMort wrote:
I wonder if anybody could suggest a way to decrease the CPU usage


I don't want to discourage you, but I think you've missed some quite important things. :->

Timing and Windows:
1. Don't mistake the performance counter value given in multiples of 100ns to be the accuracy of the performance counter.
2. Neither one of the windows operating systems are realtime OSs. Thinking in terms of microseconds is pointless in this environment.
3. Your thread will occasionally be preemted by the OS that will execute another thread for at least 10ms.

Read this[^] article for further info.

Threading issues:
When your timer expires you have to call the timer callback but that callback would be called from the context of your timer thread. This often is undesired and you will be forced to post a message to the thread that is waiting for the timer to expire to be able to execute in the correct context.
Read this[^] article to understand why.

Suggested solution:
Use multimedia timers. You'll find info about them here[^].
I've found the multimedia timers to provide the most reliable timing solution with accuracy close to 1ms.
Have the thread waiting for the timer to expire to wait for an event that is set when the timer expires by a call to ::WaitForSingleObject() or similar. The priority of the waiting thread will get boosted temporarily when the event is signalled.

Hope this helps
--
Roger




"It's supposed to be hard, otherwise anybody could do it!" - selfquote

GeneralRe: Going Loopy Pin
Waldermort15-Jan-07 6:49
Waldermort15-Jan-07 6:49 
QuestionHow to fastly write huge array or list to file ? Pin
Michael_Lotfy15-Jan-07 2:44
Michael_Lotfy15-Jan-07 2:44 
AnswerRe: How to fastly write huge array or list to file ? Pin
#realJSOP15-Jan-07 3:23
professional#realJSOP15-Jan-07 3:23 
AnswerRe: How to fastly write huge array or list to file ? Pin
Joe Woodbury15-Jan-07 6:10
professionalJoe Woodbury15-Jan-07 6:10 
QuestionAre The libmysql.lib error is system specific Pin
Y_Kaushik15-Jan-07 2:40
Y_Kaushik15-Jan-07 2:40 
AnswerRe: Are The libmysql.lib error is system specific Pin
prasad_som15-Jan-07 2:53
prasad_som15-Jan-07 2:53 
QuestionShell Extensions - Vista 64 Bit Pin
Tony Teveris15-Jan-07 2:38
Tony Teveris15-Jan-07 2:38 
QuestionDLL size Pin
PatrykDabrowski15-Jan-07 2:06
PatrykDabrowski15-Jan-07 2:06 
AnswerRe: DLL size Pin
mark novak15-Jan-07 2:28
mark novak15-Jan-07 2:28 
GeneralRe: DLL size Pin
PatrykDabrowski15-Jan-07 2:41
PatrykDabrowski15-Jan-07 2:41 
AnswerRe: DLL size Pin
#realJSOP15-Jan-07 3:25
professional#realJSOP15-Jan-07 3:25 
AnswerRe: DLL size Pin
David Crow15-Jan-07 3:28
David Crow15-Jan-07 3:28 
GeneralRe: DLL size Pin
PatrykDabrowski15-Jan-07 3:47
PatrykDabrowski15-Jan-07 3:47 
QuestionRe: DLL size Pin
David Crow15-Jan-07 3:54
David Crow15-Jan-07 3:54 
GeneralRe: DLL size Pin
PatrykDabrowski15-Jan-07 3:58
PatrykDabrowski15-Jan-07 3:58 
AnswerRe: DLL size Pin
jonny515-Jan-07 11:53
jonny515-Jan-07 11:53 
Questionneed help on VC++ 6 IDE ( begineer) Pin
Vikram.....15-Jan-07 2:02
Vikram.....15-Jan-07 2:02 

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.