Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regular expression for 0 to 1000 Pin
ScottM128-May-09 20:22
ScottM128-May-09 20:22 
AnswerRe: Regular expression for 0 to 1000 Pin
V.28-May-09 20:22
professionalV.28-May-09 20:22 
AnswerRe: Regular expression for 0 to 1000 Pin
Guffa28-May-09 20:50
Guffa28-May-09 20:50 
QuestionSearch Engine Optimization Pin
Member 426027028-May-09 18:23
Member 426027028-May-09 18:23 
AnswerRe: Search Engine Optimization Pin
Baran M28-May-09 18:44
Baran M28-May-09 18:44 
AnswerRe: Search Engine Optimization Pin
Eddy Vluggen28-May-09 21:03
professionalEddy Vluggen28-May-09 21:03 
QuestionDo something every t seconds Pin
Quake2Player28-May-09 16:41
Quake2Player28-May-09 16:41 
AnswerRe: Do something every t seconds Pin
Luc Pattyn28-May-09 17:09
sitebuilderLuc Pattyn28-May-09 17:09 
Hi,

this is a very bad idea.
Assume nextCheck has not been reached yet, then the while(true) loop is basically empty, and spinning all the time, keeping an entire core occupied. Watch the Task Manager"performance" pane: it will show 100% CPU if your system is single-core, 50% when dual-core, etc. So that is a big waste.

There is an easy fix: make sure some time elapses for free, no matter what path is taken inside the loop; i.e. when the test fails do a Thread.Sleep(x); where larger x values are less expensive, however they may decrease the accuracy of the kick-in moment. So probably 333*t is a good value, it makes you loop three times with typically two fails and one hit.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: Do something every t seconds Pin
Quake2Player28-May-09 17:45
Quake2Player28-May-09 17:45 
GeneralRe: Do something every t seconds Pin
Luc Pattyn28-May-09 17:56
sitebuilderLuc Pattyn28-May-09 17:56 
AnswerRe: Do something every t seconds Pin
Rajesh R Subramanian28-May-09 19:26
professionalRajesh R Subramanian28-May-09 19:26 
AnswerRe: Do something every t seconds Pin
Christian Graus28-May-09 19:27
protectorChristian Graus28-May-09 19:27 
AnswerRe: Do something every t seconds Pin
Mirko198029-May-09 4:19
Mirko198029-May-09 4:19 
Questionreally wierd think Pin
funic28-May-09 14:36
funic28-May-09 14:36 
Questioncreate setup package Pin
sakis2428-May-09 10:50
sakis2428-May-09 10:50 
AnswerRe: create setup package Pin
EliottA28-May-09 11:45
EliottA28-May-09 11:45 
QuestionCleaning up members of a static array property on app exit [modified] Pin
DaveyM6928-May-09 10:42
professionalDaveyM6928-May-09 10:42 
AnswerRe: Cleaning up members of a static array property on app exit Pin
Kythen28-May-09 13:36
Kythen28-May-09 13:36 
GeneralRe: Cleaning up members of a static array property on app exit [modified] Pin
DaveyM6929-May-09 10:36
professionalDaveyM6929-May-09 10:36 
QuestionExecuting Application After Installation (Using Windows Installer) Pin
BlitzPackage28-May-09 9:29
BlitzPackage28-May-09 9:29 
Generalhelp for run length encoding Pin
ali rezaiy28-May-09 8:56
ali rezaiy28-May-09 8:56 
GeneralRe: help for run length encoding Pin
harold aptroot28-May-09 10:59
harold aptroot28-May-09 10:59 
GeneralRe: help for run length encoding Pin
Alan Balkany28-May-09 11:06
Alan Balkany28-May-09 11:06 
QuestionWhat are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
ToddHileHoffer28-May-09 7:45
ToddHileHoffer28-May-09 7:45 
AnswerRe: What are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
PIEBALDconsult28-May-09 8:22
mvePIEBALDconsult28-May-09 8:22 

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.