void theServer_AccessDenied(object sender, EventArgs e) { // default reason why the server stopped. ServerStoppedReason = ServerStoppedReasons.AccessDenied; }
// Public methods: start / stop public void Start() { Functions.WriteLineToLogFile("ThreadController: Start"); if (theThread != null) { if (theThread.IsAlive) return; theThread = null; } // Record why the server stopped. ServerStoppedReason = ServerStoppedReasons.None; // start the thread Functions.WriteLineToLogFile("ThreadController: Starting server thread."); ThreadStart mainThreadStart = new ThreadStart(mainServer.Start); theThread = new Thread(mainThreadStart); // 2011-01-18: EXPERIMENTAL Use STA only. //theThread.SetApartmentState(ApartmentState.STA); // Clearly the experiment was unsuccessful. theThread.Start(); }
public void Stop() { if (theThread != null) { if (theThread.IsAlive) { // Record why the server stopped. ServerStoppedReason = ServerStoppedReasons.UserStopped; // tell the server to stop. When the ThreadEntry function exits, the thread exits mainServer.Stop(); } } // Static classes: any cleanup etc. try { StreamingManager.Default.CleanUp(); } catch { } }