/// <summary>
 /// Constructs a new BecsEngine
 /// </summary>
 public BecsEngine()
 {
     if (_mainEngine == null)
     {
         _mainEngine = this;
     }
 }
 /// <summary>
 /// Stop this service.
 /// </summary>
 protected override void OnStop()
 {
     if (_engine != null)
     {
         _engine.Stop();
         _engine = null;
     }
 }
        /// <summary>
        /// It's an application so let's start it all
        /// </summary>
        private static void ApplicationMain()
        {
            // Welcome and Start listening
            _logger = new Logger(MethodBase.GetCurrentMethod().DeclaringType);
            _logger.AddLog("*** BECS Application Started *** ", LoggerSeverities.Info);

            //OPS.Comm.Messaging.CommMain.Logger.AddLogMessage += new AddLogMessageHandler(Logger_AddLogMessage);
            //OPS.Comm.Messaging.CommMain.Logger.AddLogException += new AddLogExceptionHandler(Logger_AddLogException);

            // Start running
            BecsEngine engine = new BecsEngine();

            try
            {
                engine.Start();
            }
            catch (Exception)
            {
                engine = null;
                _logger.AddLog("An error has occurred. Quitting...", LoggerSeverities.Info);
                _logger = null;
                return;
            }

            // Wait to end
            _logger.AddLog("*** Press Enter to exit ***", LoggerSeverities.Info);
            Console.ReadLine();
            _logger.AddLog("Quitting...", LoggerSeverities.Info);

            // Stop running
            engine.Stop();

            // Clean up before we go home
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
 static BecsEngine()
 {
     _session    = new BecsSession();
     _mainEngine = null;
 }
 /// <summary>
 /// Set things in motion so your service can do its work.
 /// </summary>
 protected override void OnStart(string[] args)
 {
     // The service is starting, so create a new engine and starts it
     _engine = new BecsEngine();
     _engine.Start();
 }