Click here to Skip to main content
13,050,606 members (88,782 online)
   

C#

 
Questionhow to move picture box depending on a random dice number Pin
salhamaideh15-May-13 14:08
membersalhamaideh15-May-13 14:08 
AnswerRe: how to move picture box depending on a random dice number Pin
dusty_dex15-May-13 15:21
memberdusty_dex15-May-13 15:21 
QuestionHow to convert unix time to datetime (C#) ? Pin
Vijay Kanda6-May-13 19:35
memberVijay Kanda6-May-13 19:35 
AnswerRe: How to convert unix time to datetime (C#) ? Pin
Richard MacCutchan6-May-13 20:42
mvpRichard MacCutchan6-May-13 20:42 
AnswerRe: How to convert unix time to datetime (C#) ? Pin
Eric Lynch10-May-13 11:55
memberEric Lynch10-May-13 11:55 
QuestionCallBack to consumer using RESTful / MVC / WCF Pin
jexes23-Apr-13 22:51
memberjexes23-Apr-13 22:51 
QuestionHow to Async download multiple files using webclient simultaneously? Pin
Tridip Bhattacharjee27-Mar-13 8:01
memberTridip Bhattacharjee27-Mar-13 8:01 
Questionwebcam based credit card reader with face recognition Pin
nabil j24-Mar-13 5:44
membernabil j24-Mar-13 5:44 
AnswerRe: webcam based credit card reader with face recognition Pin
OriginalGriff24-Mar-13 5:52
mvpOriginalGriff24-Mar-13 5:52 
AnswerRe: webcam based credit card reader with face recognition Pin
DaveyM6925-Mar-13 1:10
mentorDaveyM6925-Mar-13 1:10 
Questionunable to start program, unrecognized error in windows web services framework Pin
bonosa23-Feb-13 5:06
memberbonosa23-Feb-13 5:06 
QuestionHttpwebrequest + Socks5 Pin
mathisderaltefuchs20-Feb-13 21:49
membermathisderaltefuchs20-Feb-13 21:49 
AnswerRe: Httpwebrequest + Socks5 Pin
Pete O'Hanlon21-Feb-13 2:30
protectorPete O'Hanlon21-Feb-13 2:30 
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 
AnswerRe: Thread.Sleep is NOT evil Pin
Dave Kreskowiak18-Feb-13 15:52
mvpDave Kreskowiak18-Feb-13 15:52 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 1:38
memberdevvvy19-Feb-13 1:38 
GeneralRe: Thread.Sleep is NOT evil Pin
Dave Kreskowiak19-Feb-13 1:46
mvpDave Kreskowiak19-Feb-13 1:46 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 1:49
memberdevvvy19-Feb-13 1:49 
GeneralRe: Thread.Sleep is NOT evil Pin
Dave Kreskowiak19-Feb-13 2:19
mvpDave Kreskowiak19-Feb-13 2:19 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 12:38
memberdevvvy19-Feb-13 12:38 
GeneralRe: Thread.Sleep is NOT evil Pin
Dave Kreskowiak19-Feb-13 14:03
mvpDave Kreskowiak19-Feb-13 14:03 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 14:07
memberdevvvy19-Feb-13 14:07 
AnswerRe: Thread.Sleep is NOT evil Pin
GuyThiebaut18-Feb-13 21:49
memberGuyThiebaut18-Feb-13 21:49 
GeneralRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon18-Feb-13 22:35
protectorPete O'Hanlon18-Feb-13 22:35 
GeneralRe: Thread.Sleep is NOT evil Pin
GuyThiebaut18-Feb-13 23:17
memberGuyThiebaut18-Feb-13 23:17 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 1:45
memberdevvvy19-Feb-13 1:45 
GeneralRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon19-Feb-13 2:03
protectorPete O'Hanlon19-Feb-13 2:03 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 12:44
memberdevvvy19-Feb-13 12:44 
GeneralRe: Thread.Sleep is NOT evil Pin
Pete O'Hanlon19-Feb-13 13:13
protectorPete O'Hanlon19-Feb-13 13:13 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 13:32
memberdevvvy19-Feb-13 13:32 
GeneralRe: Thread.Sleep is NOT evil Pin
GuyThiebaut19-Feb-13 2:07
memberGuyThiebaut19-Feb-13 2:07 
GeneralRe: Thread.Sleep is NOT evil Pin
devvvy19-Feb-13 12:41
memberdevvvy19-Feb-13 12:41 
GeneralRe: Thread.Sleep is NOT evil Pin
BobJanova18-Feb-13 23:56
memberBobJanova18-Feb-13 23:56 

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
Web02 | 2.8.170713.1 | Last Updated 25 Jul 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid