473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Nov 15 '05 #1
2 7664
grant <gr**********@hotmail.com> wrote:
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?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
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" <gr**********@hotmail.com> wrote in message
news:cd**************************@posting.google.c om...
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

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: ...
7
by: brisers | last post by:
Hello, After studying some of the available resouces ( http://msdn.microsoft.com/msdnmag/issues/04/05/BasicInstincts/default.aspx) I can see that it is forbidden to modify the UI directly from...
14
by: Joe | last post by:
Does anyone know the difference, in practical terms, between Thread.Sleep (10000) and Thread.CurrentThread.Join (10000)?? The MSDN says that with Join, standard COM and SendMessage pumping...
2
by: many_years_after | last post by:
Hi,pythoners: I countered some problems when I try to stop threads using flag. These are my some important codes: ##### mythread.py def run(self): while self.addr != '': ### text waiting...
4
by: Eran.Yasso | last post by:
Hi, Is there a way to stop a loop running in a thread using bool? What i mean is: i have two classes. When i click button(classA) on, i starts running s thread(classB) which is located...
6
by: kdikert | last post by:
I have a worker thread, and when the worker is done I want it to show a popup dialog. The sample application below demonstrates this. There are two buttons: a "Show dialog" button which immediately...
1
by: Chrace | last post by:
Hi all, I have a problem with with Thread.Join( Timeout ) where the timeout never occurs. I basically need to make a connection to an AS400 box which works fine. Once in a blue moon the AS400...
4
by: hussain3047 | last post by:
Hi i am a beginner in C sharp and trying to develop a wince 5.0 device application using C sharp. i am using a thread in the Form1 Load method which is continously running a method named...
2
by: ssouhrada | last post by:
I have some code below which Queues up Worker Items... The only thing it doesn't do is wait for the application to finish executing it. Any ideas on how I can get the application wait for all these...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.