Thread.sleep(10000) is using 100% cpu

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
 
J

Jon Skeet [C# MVP]

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?
 
A

Alvin Bruney

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top