public void AssignRunningReceiveThread(ReceiveThread InThread) { if (mRunningReceiveThread != null) { throw new Exception("ReceiveThread is already assigned as running"); } mRunningReceiveThread = InThread; }
public void UnassignRunningReceiveThread(ReceiveThread InThread) { if (mRunningReceiveThread != InThread) { throw new Exception("Receive thread to unassign is not assigned as running"); } mRunningReceiveThread = null; }
// ------------------------- ThreadStart ----------------------------- public static void ThreadStart(ReceiveThread InThread) { ThreadStart job = new ThreadStart(InThread.EntryPoint); Thread t = new Thread(job); t.IsBackground = true; t.Start(); }
public void ShutdownThreads() { foreach (CommandThread ct in mCommandThreadList) { ct.InitiateThreadShutdown(); // wait for the command thread to end. ct.ThreadEndedEvent.WaitOne(); } // instruct the receive thread to shutdown. ReceiveThread rrt = RunningReceiveThread; if ((rrt != null) && (rrt.IsRunning == true)) { rrt.InitiateThreadShutdown(); mRunLog.Write("Wait for ReceiveThread to end ..."); rrt.ThreadEndedEvent.WaitOne(); } }
// ---------------------- StartReceiveFromTelnetServerThread ---------------------- public static void StartReceiveFromTelnetServerThread( // out DataQueue OutReceiveDataQueue, out AutoResetEvent OutStartReceivingEvent, TelnetConnection InConn, ThreadSupervisor InSupervisor, ExtendedManualResetEvent InShutdownFlag, RunLogListBox InRunLog) { // create the event that the receive thread listens to to be signaled that it // should wake up and receive from the telnet server. OutStartReceivingEvent = new AutoResetEvent(false); // setup the ReceiveThread object with all the object references it needs. ReceiveThread rt = new ReceiveThread( InConn, OutStartReceivingEvent, InSupervisor, InShutdownFlag, InRunLog); // start the ReceiveThread. ReceiveThread.ThreadStart(rt); }