Thread.sleep(10000) is using 100% cpu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • grant

    #1

    Thread.sleep(10000) is using 100% cpu

    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
  • Jon Skeet [C# MVP]

    #2
    Re: Thread.sleep(10 000) is using 100% cpu

    grant <grant_currey@h otmail.com> wrote:[color=blue]
    > 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?[/color]

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

    using System;
    using System.Threadin g;

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

    or is it only within the application you're trying to write?

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Alvin Bruney

      #3
      Re: Thread.sleep(10 000) is using 100% cpu

      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.

      "grant" <grant_currey@h otmail.com> wrote in message
      news:cd4f0940.0 310121531.57a55 6ff@posting.goo gle.com...[color=blue]
      > 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[/color]


      Comment

      Working...