"not_a_commie" <no********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
>I need code to peg the CPU for 10 seconds to test some background
threads. Sleep obviously doesn't do that. How do I code a busy loop
that won't get removed by the compiler? Thanks.
DateTime endTime = DateTime.Now.AddSeconds(10);
int i = 0;
while (DateTime.Now < endTime) { i++; }
You'd have to run 2 or 3 instances of this program at once to really peg the
CPU though...on my machine, something is preventing the app from using more
than 50% of the CPU per process...which, is pretty good since I don't want
any apps bogging down my system :)
HTH,
Mythran