protected override void OnStart(string[] args)
        {
            Logger.SetPath(Path.GetTempPath() + "CeServiceNet.log");
            Logger.Info(string.Format("CeServiceNet.Starting ..."));

            try
            {
                Logger.Info(string.Format("Starting CeService..."));
                _serviceHost = CeService.Start();
                _Started     = true;
            }
            catch
            {
                Stop();
            }
        }
        protected override void OnStop()
        {
            if (_serviceHost != null)
            {
                Logger.Info(string.Format("Stopping ServiceHost..."));
                _serviceHost.Close();
                _serviceHost = null;
            }

            try
            {
                Logger.Info(string.Format("Stopping CeService..."));
                if (_Started)
                {
                    CeService.Stop();
                    _Started = false;
                }
            }
            catch { }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Logger.SetPath(Path.GetTempPath() + "CeHostNet.log");
            Logger.Info(string.Format("CeHostNet.Starting ..."));

            try
            {
                Logger.Info(string.Format("Starting CeService..."));
                _serviceHost = CeService.Start();

                Console.WriteLine("CeService is started");

                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
            }
            catch
            {
                Console.WriteLine("Service failed to start");
                return;
            }

            try
            {
                Logger.Info(string.Format("Stopping CeService..."));
                CeService.Stop();
            }
            catch
            {
                Console.WriteLine("Service failed to stop");
            }

            if (_serviceHost != null)
            {
                _serviceHost.Close();
            }
        }