private void StopThreads()
{
if (fAborted) return;
try
{
Thread stopper = new Thread(new ThreadStart(delegate()
{
fFinalizerActive = true;
Thread.Sleep(100);
try
{
lock (fMoveQ) {
Monitor.Pulse(fMoveQ);
}
JoinWith(fMoveThread, 1);
fMoveThread = null;
JoinWith(fListPlayersThread, 1);
fListPlayersThread = null;
lock (fPriorityFetchQ) {
Monitor.Pulse(fPriorityFetchQ);
}
JoinWith(fFetchThread, 1);
fFetchThread = null;
lock (fScramblerLock) {
fScramblerLock.MaxDelay = 0;
Monitor.Pulse(fScramblerLock);
}
JoinWith(fScramblerThread, 1);
fScramblerThread = null;
lock (fTimerRequestList) {
Monitor.Pulse(fTimerRequestList);
}
JoinWith(fTimerThread, 1); // checks for null
fTimerThread = null;
}
catch (Exception e)
{
ConsoleException(e);
}
fFinalizerActive = false;
ConsoleWrite("^1^bFinished disabling threads, ready to be enabled again!", 0);
}));
stopper.Name = "stopper";
stopper.IsBackground = true;
stopper.Start();
}
catch (Exception e)
{
if (!fAborted) ConsoleException(e);
}
}