Click here to Skip to main content
15,900,724 members
Home / Discussions / C#
   

C#

 
GeneralRe: for (;;) Pin
Joe Woodbury19-Aug-08 18:40
professionalJoe Woodbury19-Aug-08 18:40 
GeneralRe: for (;;) Pin
chaiguy133719-Aug-08 18:43
chaiguy133719-Aug-08 18:43 
GeneralRe: for (;;) Pin
Joe Woodbury19-Aug-08 19:26
professionalJoe Woodbury19-Aug-08 19:26 
GeneralRe: for (;;) Pin
MarkB77719-Aug-08 17:13
MarkB77719-Aug-08 17:13 
GeneralRe: for (;;) Pin
Stephen Hewitt19-Aug-08 18:01
Stephen Hewitt19-Aug-08 18:01 
GeneralRe: for (;;) Pin
Colin Angus Mackay19-Aug-08 21:30
Colin Angus Mackay19-Aug-08 21:30 
GeneralRe: for (;;) Pin
MarkB77720-Aug-08 1:29
MarkB77720-Aug-08 1:29 
GeneralRe: for (;;) Pin
Mark Churchill19-Aug-08 21:04
Mark Churchill19-Aug-08 21:04 
This is something I personally don't agree with. I think the while(condition) is much clearer as to its intent. The compiler warnings of constant-in-conditional are warning of possibly unintended code, when it this case it is 100% intentional.

That said, its not very often you need to actually have an infinite loop. Usually threads with while(true) should be implemented with while(!done). (Often they are stopped with ThreadAbort in random places)

I also see a lot of while { if(!data) sleep(1); else process();} patterns instead of re-registering at the end of an async callback.

Some of the worst maintenance nightmares have been on supposedly "high avaliability" systems with a lot of that. Small sleep intervals often return immediately, and theres not much point trying to sleep for less than a scheduling quanta. Things that need to be done quickly (priority), but infrequently are often poorly implemented with the while-sleep(1) pattern, leading to a tight loop that sucks down CPU. People need to learn how to use Monitor.* Wink | ;)


GeneralRe: for (;;) Pin
chaiguy133720-Aug-08 9:01
chaiguy133720-Aug-08 9:01 
GeneralRe: for (;;) Pin
MarkB77719-Aug-08 17:13
MarkB77719-Aug-08 17:13 
GeneralRe: for (;;) Pin
Bassam Saoud19-Aug-08 17:15
Bassam Saoud19-Aug-08 17:15 
AnswerRe: for (;;) Pin
Paul Conrad19-Aug-08 19:47
professionalPaul Conrad19-Aug-08 19:47 
AnswerRe: for (;;) Pin
leppie19-Aug-08 23:08
leppie19-Aug-08 23:08 
QuestionSomeone Explain Delegates To Me Pin
Kevin Marois19-Aug-08 11:07
professionalKevin Marois19-Aug-08 11:07 
AnswerRe: Someone Explain Delegates To Me Pin
Guffa19-Aug-08 11:14
Guffa19-Aug-08 11:14 
AnswerRe: Someone Explain Delegates To Me PinPopular
led mike19-Aug-08 11:15
led mike19-Aug-08 11:15 
JokeRe: Someone Explain Delegates To Me Pin
Bassam Saoud19-Aug-08 15:16
Bassam Saoud19-Aug-08 15:16 
GeneralRe: Someone Explain Delegates To Me Pin
CPallini19-Aug-08 22:25
mveCPallini19-Aug-08 22:25 
AnswerRe: Someone Explain Delegates To Me Pin
vikas amin19-Aug-08 11:50
vikas amin19-Aug-08 11:50 
AnswerRe: Someone Explain Delegates To Me Pin
chaiguy133719-Aug-08 15:26
chaiguy133719-Aug-08 15:26 
AnswerRe: Someone Explain Delegates To Me Pin
Mark Churchill19-Aug-08 21:15
Mark Churchill19-Aug-08 21:15 
GeneralRe: Someone Explain Delegates To Me Pin
Csharp_Raja19-Aug-08 23:01
Csharp_Raja19-Aug-08 23:01 
QuestionWhat Are Structs For In C#? Pin
Kevin Marois19-Aug-08 11:03
professionalKevin Marois19-Aug-08 11:03 
AnswerRe: What Are Structs For In C#? Pin
Guffa19-Aug-08 11:11
Guffa19-Aug-08 11:11 
AnswerRe: What Are Structs For In C#? Pin
vikas amin19-Aug-08 11:53
vikas amin19-Aug-08 11:53 

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.