Esempio n. 1
0
        /// <summary>
        /// Starts three independent threads who perform reflector server's tasks.
        /// </summary>
        public void StartReflector()
        {
            try
            {
                pC = new ReflectorPC("Reflector");

                sockets.InitAll(enabledTrafficTypes);
                regServer.StartThreads();
                UMforwarder.StartThreads();
                MUforwarder.StartThreads();

                isRunning = true;

                eventLog.WriteEntry("ReflectorService started", EventLogEntryType.Information,
                                    (int)ReflectorEventLog.ID.ServiceStarted);
            }
            catch (Exception e)
            {
                eventLog.WriteEntry("ReflectorService starting exception" + e.ToString(), EventLogEntryType.Error,
                                    (int)ReflectorEventLog.ID.ThreadStartingException);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Stops the reflector.
        /// </summary>
        public void StopReflector()
        {
            isRunning = false;

            try
            {
                // On 64-bit machines, the call to UMforwarder.StopThreads() would seemingly
                // not stop threads and the call to MUforwarder.StopThreads() would seemingly
                // abort the thread that was stopping the service, leaving the service in an
                // uncontrollable state.  Since all the threads were created with
                // Background = true, we decided to remove the calls to stop the
                // threads.  The service works fine.  Now we get some additional
                // warnings (count varies) in the event log, because the threads
                // are sometimes stopped by the process exiting, and sometimes
                // by the socket being closed.

                //regServer.StopThreads();
                //UMforwarder.StopThreads();
                //MUforwarder.StopThreads();

                // regServer no longer has separate listening sockets
                //regServer.StopListening();

                sockets.DisposeAll();
                pC.Dispose();
                pC = null;
                eventLog.WriteEntry(Strings.ReflectorServiceStopped, EventLogEntryType.Information,
                                    (int)ReflectorEventLog.ID.ServiceStopped);
            }
            // On stopping the service, avoid the AbortException written in the event viewer
            catch (ThreadAbortException) { }
            catch (Exception e)
            {
                eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture,
                                                  Strings.ReflectorServiceStoppingException, e.ToString()), EventLogEntryType.Warning,
                                    (int)ReflectorEventLog.ID.ThreadStoppingException);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Stops the reflector.
        /// </summary>
        public void StopReflector()
        {
            isRunning = false;

            try
            {
                regServer.StopThreads();
                UMforwarder.StopThreads();
                MUforwarder.StopThreads();
                sockets.DisposeAll();
                pC.Dispose();
                pC = null;
                eventLog.WriteEntry("ReflectorService stopped", EventLogEntryType.Information,
                                    (int)ReflectorEventLog.ID.ServiceStopped);
            }
            // On stopping the service, avoid the AbortException written in the event viewer
            catch (ThreadAbortException) {}
            catch (Exception e)
            {
                eventLog.WriteEntry("ReflectorService stopping exception" + e.ToString(), EventLogEntryType.Warning,
                                    (int)ReflectorEventLog.ID.ThreadStoppingException);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Starts three independent threads who perform reflector server's tasks.
        /// </summary>
        public void StartReflector()
        {
            try
            {
                pC = new ReflectorPC("Reflector");

                sockets.InitAll(enabledTrafficTypes);

                UMforwarder.StartThreads();
                MUforwarder.StartThreads();

                isRunning = true;

                eventLog.WriteEntry(Strings.ReflectorServiceStarted, EventLogEntryType.Information,
                                    (int)ReflectorEventLog.ID.ServiceStarted);
            }
            catch (Exception e)
            {
                eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture,
                                                  Strings.ReflectorServiceStartingException, e.ToString()), EventLogEntryType.Error,
                                    (int)ReflectorEventLog.ID.ThreadStartingException);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Stops the reflector.
        /// </summary>
        public void StopReflector()
        {
            isRunning = false;

            try
            {
                regServer.StopThreads();
                UMforwarder.StopThreads();
                MUforwarder.StopThreads();
                sockets.DisposeAll();
                pC.Dispose();
                pC = null;
                eventLog.WriteEntry("ReflectorService stopped", EventLogEntryType.Information,
                    (int)ReflectorEventLog.ID.ServiceStopped);
            }
            // On stopping the service, avoid the AbortException written in the event viewer
            catch(ThreadAbortException){}
            catch(Exception e)
            {
                eventLog.WriteEntry("ReflectorService stopping exception" + e.ToString() , EventLogEntryType.Warning,
                    (int)ReflectorEventLog.ID.ThreadStoppingException);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Starts three independent threads who perform reflector server's tasks.
        /// </summary>
        public void StartReflector()
        {
            try
            {
                pC = new ReflectorPC("Reflector");

                sockets.InitAll(enabledTrafficTypes);
                regServer.StartThreads();
                UMforwarder.StartThreads();
                MUforwarder.StartThreads();

                isRunning = true;

                eventLog.WriteEntry("ReflectorService started", EventLogEntryType.Information,
                    (int)ReflectorEventLog.ID.ServiceStarted);
            }
            catch(Exception e)
            {
                eventLog.WriteEntry("ReflectorService starting exception" + e.ToString() , EventLogEntryType.Error,
                    (int)ReflectorEventLog.ID.ThreadStartingException);

            }
        }
Esempio n. 7
0
        /// <summary>
        /// Stops the reflector.
        /// </summary>
        public void StopReflector()
        {
            isRunning = false;

            try
            {
                // On 64-bit machines, the call to UMforwarder.StopThreads() would seemingly
                // not stop threads and the call to MUforwarder.StopThreads() would seemingly
                // abort the thread that was stopping the service, leaving the service in an
                // uncontrollable state.  Since all the threads were created with
                // Background = true, we decided to remove the calls to stop the
                // threads.  The service works fine.  Now we get some additional
                // warnings (count varies) in the event log, because the threads
                // are sometimes stopped by the process exiting, and sometimes
                // by the socket being closed.

                //regServer.StopThreads();
                //UMforwarder.StopThreads();
                //MUforwarder.StopThreads();

                // regServer no longer has separate listening sockets
                //regServer.StopListening();

                sockets.DisposeAll();
                pC.Dispose();
                pC = null;
                eventLog.WriteEntry(Strings.ReflectorServiceStopped, EventLogEntryType.Information,
                    (int)ReflectorEventLog.ID.ServiceStopped);
            }
            // On stopping the service, avoid the AbortException written in the event viewer
            catch (ThreadAbortException) { }
            catch (Exception e)
            {
                eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture,
                    Strings.ReflectorServiceStoppingException, e.ToString()), EventLogEntryType.Warning,
                    (int)ReflectorEventLog.ID.ThreadStoppingException);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Starts three independent threads who perform reflector server's tasks.
        /// </summary>
        public void StartReflector()
        {
            try
            {
                pC = new ReflectorPC("Reflector");

                sockets.InitAll(enabledTrafficTypes);
                
                UMforwarder.StartThreads();
                MUforwarder.StartThreads();

                isRunning = true;

                eventLog.WriteEntry(Strings.ReflectorServiceStarted, EventLogEntryType.Information,
                    (int)ReflectorEventLog.ID.ServiceStarted);
            } 
            catch(Exception e)
            {
                eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, 
                    Strings.ReflectorServiceStartingException, e.ToString()), EventLogEntryType.Error,
                    (int)ReflectorEventLog.ID.ThreadStartingException);

            }
        }