Thread.sleep(10000) is using 100% cpu

  • Thread starter Thread starter grant
  • Start date Start date
G

grant

Hi,

I have an interesting threading issue in c#. I put a thread to sleep
for an arbitary period of time, during this period the cpu jumps
straight to 100% utilization. As one could guess this is very
anoying.

any suggestions on why?

Regards

grant
 
grant said:
I have an interesting threading issue in c#. I put a thread to sleep
for an arbitary period of time, during this period the cpu jumps
straight to 100% utilization. As one could guess this is very
anoying.

any suggestions on why?

Does it happen with a simple test program, such as:

using System;
using System.Threading;

class Test
{
static void Main()
{
Thread.Sleep (10000);
}
}

or is it only within the application you're trying to write?
 
you have obviously got something else going on in the background. sleep is a
very efficient wait state. you may be able to use the debugger to figure
this one out. run the application, and open the thread watch window, you
will be able to see exactly which thread is hogging the cpu. It's a good
idea to name the threads so they appear named in the watch window.
 
Back
Top