Alex Moskalyuk <us****@moskalyuk.com> wrote:
Have a variable incremented in KeyDown event.
Which KeyDown event is that, in a console app?
Print out the message "Press any key..."
AforeMentionedVariable = 0;
while (AforeMentionedVariable == 0);
That's not guaranteed to *ever* finish, unless the variable is volatile
- and even if the variable were volatile, you'd still be taking up 100%
CPU until someone pressed a key. Tight loops like that should (almost)
never be used for that kind of thing - it's what Monitor.Wait/Pulse was
designed for.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too