Click here to Skip to main content
12,444,360 members (48,174 online)
   

C#

 
AnswerRe: C# run a process Pin
Eddy Vluggen18-Feb-13 7:48
mvpEddy Vluggen18-Feb-13 7:48 
GeneralRe: C# run a process Pin
classy_dog18-Feb-13 8:22
memberclassy_dog18-Feb-13 8:22 
GeneralRe: C# run a process Pin
Eddy Vluggen18-Feb-13 8:30
mvpEddy Vluggen18-Feb-13 8:30 
GeneralRe: C# run a process Pin
classy_dog18-Feb-13 14:04
memberclassy_dog18-Feb-13 14:04 
GeneralRe: C# run a process Pin
Eddy Vluggen18-Feb-13 22:31
mvpEddy Vluggen18-Feb-13 22:31 
GeneralRe: C# run a process Pin
classy_dog19-Feb-13 5:38
memberclassy_dog19-Feb-13 5:38 
GeneralRe: C# run a process Pin
Eddy Vluggen19-Feb-13 9:34
mvpEddy Vluggen19-Feb-13 9:34 
QuestionThread.Sleep is NOT evil Pin
devvvy18-Feb-13 5:55
memberdevvvy18-Feb-13 5:55 
Some argue Thread.Sleep is evil - [^]

Thread.Sleep is one-line of code, simple, and get the job done. I must say I disagree with the author of this ... discussion referenced.


SCENARIO 1 - wait for async task completion: I agree that WaitHandle/Auto|ManualResetEvent should be used in scenario where a thread is waiting for task on another thread to complete.

SCENARIO 2 - humble timing while loop: However, as a crude timing mechanism (while+Thread.Sleep) is perfectly fine for 99% of applications which does NOT require knowing exactly when the blocked Thread should "wake up*. The argument that it takes 200k cycles to create the thread is also invalid - the timing loop thread needs be created anyway and 200k cycles is just another big number (tell me how many cycles to open a file/socket/db calls?).

So if while+Thread.Sleep works, why complicate things?

dev

AnswerRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon18-Feb-13 6:15
protectorPete O'Hanlon18-Feb-13 6:15 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy18-Feb-13 13:29
memberdevvvy18-Feb-13 13:29 
GeneralRe: Thread.Sleep is NOT evil Pin
N a v a n e e t h18-Feb-13 16:12
memberN a v a n e e t h18-Feb-13 16:12 
GeneralTHANK YOU - this is the answer I was looking for. Pin
devvvy19-Feb-13 12:53
memberdevvvy19-Feb-13 12:53 
GeneralRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon18-Feb-13 20:43
protectorPete O'Hanlon18-Feb-13 20:43 
GeneralApplication Exit vs Thread.Abort? Pin
devvvy19-Feb-13 13:12
memberdevvvy19-Feb-13 13:12 
GeneralRe: Thread.Sleep is NOT evil Pin
Simon_Whale18-Feb-13 13:41
memberSimon_Whale18-Feb-13 13:41 
GeneralRe: Thread.Sleep is NOT evil Pin
N a v a n e e t h18-Feb-13 16:15
memberN a v a n e e t h18-Feb-13 16:15 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 1:41
memberdevvvy19-Feb-13 1:41 
GeneralRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon19-Feb-13 2:18
protectorPete O'Hanlon19-Feb-13 2:18 
GeneralRe: Thread.Sleep is NOT evil Pin
N a v a n e e t h19-Feb-13 6:33
memberN a v a n e e t h19-Feb-13 6:33 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 12:47
memberdevvvy19-Feb-13 12:47 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 12:35
memberdevvvy19-Feb-13 12:35 
GeneralRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon19-Feb-13 13:06
protectorPete O'Hanlon19-Feb-13 13:06 
GeneralApplication exit: Valid concern for SCENARIO 2 from Pete (Big thank you!) Pin
devvvy19-Feb-13 13:30
memberdevvvy19-Feb-13 13:30 
GeneralRe: Thread.Sleep is NOT evil Pin
N a v a n e e t h19-Feb-13 6:36
memberN a v a n e e t h19-Feb-13 6:36 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 12:36
memberdevvvy19-Feb-13 12:36 

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.


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 23 Aug 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid