473,473 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Thread Ssuspend / CPU Usage 100%

I have a static ServiceFactory. After suspending the thread, the CPU is using 100% CPU. There is no way in debugging this error. Could you give me a hint?
Code:

using System;
using System.Threading;

namespace XY
{

public class ServicesFactory
{
private static Playerlist playerlist;
private static CardDeck cardDeck;
private static Scoreboard scoreboard;
private static RowMaster rowMaster;
private static Dealer dealer;
private static RemoteEntryPoint remoteEntryPoint;
private static Thread mainThread;

private ServicesFactory(){}

/// <summary>
/// Property Dealer
/// </summary>
public static Dealer Dealer
{
get
{
if(dealer == null)
dealer = new Dealer();

return dealer;
}
}
/// <summary>
/// Property RowMaster
/// </summary>
public static RowMaster RowMaster
{
get
{
if(rowMaster == null)
rowMaster = new RowMaster();

return rowMaster;
}
}


public static void HostRun()
{
Console.WriteLine(">>> HOST:HostRun.");
if(mainThread == null)
mainThread = Thread.CurrentThread;

if(mainThread.ThreadState == ThreadState.Suspended)
{
mainThread.Resume();
Console.WriteLine(">>> HOST WURDE FORTGESETZT (resume).");
}
}
public static void HostWait()
{
Console.WriteLine(">>> HOST:HostWait.");
if(mainThread == null)
mainThread = Thread.CurrentThread;

Console.WriteLine(">>> HOST WURDE ANGEHALTEN (suspend).");
mainThread.Suspend();
}

}
}

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>xXZzcH8YU0m3DDuEGCm+1A==</Id>
Nov 16 '05 #1
1 1533
I'm confused - without seeing the driving code I'm not sure how this works. HostRun seems like its broken

It stores the current thread then checks to see if its suspended, if it is it resumes it. Obviously HostRun will not execute if the current thread is suspended. So I can only guess that HostRun or HostWait are called to "prime" the mainThread member.

You need to supply more info so we can try to diagnose the problem

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

I have a static ServiceFactory. After suspending the thread, the CPU is using 100% CPU. There is no way in debugging this error. Could you give me a hint?
Code:

using System;
using System.Threading;

namespace XY
{

public class ServicesFactory
{
private static Playerlist playerlist;
private static CardDeck cardDeck;
private static Scoreboard scoreboard;
private static RowMaster rowMaster;
private static Dealer dealer;
private static RemoteEntryPoint remoteEntryPoint;
private static Thread mainThread;

private ServicesFactory(){}

/// <summary>
/// Property Dealer
/// </summary>
public static Dealer Dealer
{
get
{
if(dealer == null)
dealer = new Dealer();

return dealer;
}
}
/// <summary>
/// Property RowMaster
/// </summary>
public static RowMaster RowMaster
{
get
{
if(rowMaster == null)
rowMaster = new RowMaster();

return rowMaster;
}
}


public static void HostRun()
{
Console.WriteLine(">>> HOST:HostRun.");
if(mainThread == null)
mainThread = Thread.CurrentThread;

if(mainThread.ThreadState == ThreadState.Suspended)
{
mainThread.Resume();
Console.WriteLine(">>> HOST WURDE FORTGESETZT (resume).");
}
}
public static void HostWait()
{
Console.WriteLine(">>> HOST:HostWait.");
if(mainThread == null)
mainThread = Thread.CurrentThread;

Console.WriteLine(">>> HOST WURDE ANGEHALTEN (suspend).");
mainThread.Suspend();
}

}
}

Nov 16 '05 #2

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

Similar topics

2
by: Mark McKay | last post by:
I have a thread which is used for updating a display window. The normal paint message queue is being bypassed in favor of drawing on demand by this thread. This thread is passed a Graphics...
9
by: phil | last post by:
And sorry I got ticked, frustrating week >And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place,...
8
by: Cider123 | last post by:
I ran into a situation where my Window Service had to process 100,000+ files, when I first noticed I needed to tweak various routines. Everything runs fine, but here's what I ran into: In the...
3
by: Santosh | last post by:
Hi, I have a requirement while using ThreadPool class. I am creating n number of threads using ThreadPool class, using WaitCallback method. In this Method I want to stop all the threads started...
10
by: Curious | last post by:
Hi, I have a worker thread running, where basically its operation is to execute in an infinite loop. Now, when I am suspending this thread, the CPU usage time is still remaining 100%. What...
11
by: Michael Moreno | last post by:
Hello, I have a C# server which has 4 worker threads running all the time. When I let the server runs for several hours, for some reasons the CPU usage of the application will shoot to 100% and...
5
by: fniles | last post by:
I am having problem with thread. I have a Session class with public string variable (called Message) that I set from my Main program. In the session class it checks for the value of Message...
8
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I have an application with several BackgroundWorker threads. I hoped I'd be able to just type backgroundworker1.Name = "bw1"; but I don't see a name property. Any thoughts on how to name a...
1
by: ASPnewb1 | last post by:
Hello. I've developed an application that reads at a constant fast rate, bytes from a serial port, and posts these to a textbox on the main form. Basically a serial port monitor of sorts...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.