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>