示例#1
0
 void theServer_AccessDenied(object sender, EventArgs e)
 {
     // default reason why the server stopped.
     ServerStoppedReason = ServerStoppedReasons.AccessDenied;
 }
示例#2
0
        // 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();
        }
示例#3
0
        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 { }
        }