Click here to Skip to main content
15,946,529 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionVS 2003 IDE issue Pin
matthias s.4-Nov-05 1:56
matthias s.4-Nov-05 1:56 
QuestionUrlEditor doesn't display in design time Pin
smoitry3-Nov-05 22:50
smoitry3-Nov-05 22:50 
Questionfile monitoring low level Pin
UgoDeschamps3-Nov-05 6:40
UgoDeschamps3-Nov-05 6:40 
AnswerRe: file monitoring low level Pin
Dave Kreskowiak3-Nov-05 14:05
mveDave Kreskowiak3-Nov-05 14:05 
QuestionInsert Line of Text in Text File Pin
Rabbit173-Nov-05 6:08
Rabbit173-Nov-05 6:08 
AnswerRe: Insert Line of Text in Text File Pin
Rabbit173-Nov-05 7:31
Rabbit173-Nov-05 7:31 
GeneralRe: Insert Line of Text in Text File Pin
Dave Kreskowiak3-Nov-05 14:03
mveDave Kreskowiak3-Nov-05 14:03 
Question.NET Threads taking CPU time while suspended Pin
khariv2-Nov-05 22:58
khariv2-Nov-05 22:58 
I am running into a very frustrating problem with an application which works with threads.

Basically, what I am doing is creating a number of threads which I use for executing procedures. I cannot use the thread pool as the application does not suit itself to that sort of methodology (I will need to have greater control over the individual threads). For this reason, I am creating threads and keeping them around until I need them and then using them as needed.

Anyway, what I am seeing is that, if I have my threadStart procedure use a "while not terminated" type loop, the thread takes up lots of CPU time. For example, here is the ThreadStart:
private void doSomething()
{
while (fKillThread != true)
{
doSomethingElse()
System.Threading.Thread.CurrentThread.Suspend();
}
}

In theory, this should run ONCE and then suspend itself and take no further CPU time. However that is definitely not the case. Instead, these threads peg the CPU at 100%. It is almost as if it is continuously evaluating the while condition instead of doing it once and suspending.

So, why does .NET Thread.Suspend() not actually put the thread to sleep until it is called inside of a while loop?

If I eliminate the while loop and just call suspend(), it suspends and takes no CPU time at all.

Can anyone shed some light on what is going on here?

thanks

[edit]

I found this post that looks like the same thing is happening:
http://www.highdots.com/forums/visual-studio-net-debugging/thread-suspend-causes-100-cpu-2194189.html

this was from back in 2003 - anyone know if it was ever fixed or is .NET threading just broken until I upgrade to 2.0? Is it fixed there???
khariV


-- modified at 5:02 Thursday 3rd November, 2005
AnswerRe: .NET Threads taking CPU time while suspended Pin
akyriako782-Nov-05 23:56
akyriako782-Nov-05 23:56 
GeneralRe: .NET Threads taking CPU time while suspended Pin
khariv3-Nov-05 5:32
khariv3-Nov-05 5:32 
GeneralRe: .NET Threads taking CPU time while suspended Pin
akyriako783-Nov-05 10:25
akyriako783-Nov-05 10:25 
AnswerRe: .NET Threads taking CPU time while suspended Pin
akyriako782-Nov-05 23:57
akyriako782-Nov-05 23:57 
AnswerRe: .NET Threads taking CPU time while suspended Pin
S. Senthil Kumar3-Nov-05 1:02
S. Senthil Kumar3-Nov-05 1:02 
QuestionOnPaintBackground isn't getting called Pin
OlliesDad2-Nov-05 12:21
OlliesDad2-Nov-05 12:21 
AnswerRe: OnPaintBackground isn't getting called Pin
OlliesDad2-Nov-05 13:23
OlliesDad2-Nov-05 13:23 
QuestionPInvokeStackImbalance (Net 2.0) Pin
Angelo Cresta2-Nov-05 3:32
professionalAngelo Cresta2-Nov-05 3:32 
AnswerRe: PInvokeStackImbalance (Net 2.0) Pin
Angelo Cresta3-Nov-05 3:29
professionalAngelo Cresta3-Nov-05 3:29 
QuestionWaveform audio interface component for .NET Pin
AdamSlosarski2-Nov-05 1:50
AdamSlosarski2-Nov-05 1:50 
Questiondotfuscation Pin
D.N.1-Nov-05 20:55
D.N.1-Nov-05 20:55 
AnswerRe: dotfuscation Pin
enjoycrack2-Nov-05 6:47
enjoycrack2-Nov-05 6:47 
QuestionIDispose Pin
D.N.1-Nov-05 20:53
D.N.1-Nov-05 20:53 
AnswerRe: IDispose Pin
Christian Graus2-Nov-05 13:34
protectorChristian Graus2-Nov-05 13:34 
AnswerRe: IDispose Pin
Colin Angus Mackay3-Nov-05 1:30
Colin Angus Mackay3-Nov-05 1:30 
GeneralRe: IDispose Pin
Christian Graus3-Nov-05 11:17
protectorChristian Graus3-Nov-05 11:17 
GeneralRe: IDispose Pin
Leather994-Nov-05 2:52
Leather994-Nov-05 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.