Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
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 
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 
Hi,

1.
your snippet is acceptable under most circumstances. The one problem with it is this: let us assume we are in the else part, just finished the subtraction, and are going to launch the sleep; suddenly the system decides to switch threads because something higher-priority kicked in; after three seconds, the higher-priority thing is back, and your thread now goes to sleep voluntarily, for a timespan that is of by three seconds. Bad luck.

When you have a fixed sleep as in <thread.sleep(333*t)< code=""> your thread will try and loop once every 333 msec (assuming t=1), or 666 msec (for t=2), etc. so effectively for a repeat of t seconds it will try three times, failing two and succeeding one. The 333 stems from 1000 milliseconds per second, and 3 short sleeps for 1 activation of the "do the thing".


2.
yes Thread.Sleep() is always executed by the thread that executes it, just like "I am myself" and "it now is today". All always true.

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.

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 
AnswerRe: What are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
Henry Minute28-May-09 8:43
Henry Minute28-May-09 8:43 
GeneralRe: What are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
ScottM128-May-09 20:21
ScottM128-May-09 20:21 

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.