Пример #1
0
        /// <summary>
        /// Punto de entrada principal para la aplicación.
        /// </summary>
        static void Main()
        {
            #if (!DEBUG)
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new Service1()
            };
            ServiceBase.Run(ServicesToRun);
            ServiceBase.Run(ServicesToRun);
#else
            Service1 myServ = new Service1();
            logger.Info("Servicio Cerberus.ATC.Gateway.V2.Service iniciado");
            TCPServer server = null;

            try
            {
                IPAddress ipAddress = IPAddress.Parse(Tunnel.Get_ip_local_address());
                server = new TCPServer(ipAddress, puerto);

                server.StartServer();
            }
            catch (Exception ex)
            {
                logger.Error(" Error al iniciar servicio,detalle:" + ex.Message + ex.InnerException + ex.StackTrace);
            }
            // here Process is my Service function
            // that will run when my service onstart is call
            // you need to call your own method or function name here instead of Process();
#endif
        }
Пример #2
0
        protected override void OnStart(string[] args)
        {
            logger.Info("Servicio Cerberus.ATC.Gateway.V2.Service iniciado");
            try
            {
                IPAddress ipAddress = IPAddress.Parse(Tunnel.Get_ip_local_address());
                server = new TCPServer(ipAddress, puerto);

                server.StartServer();
            }
            catch (Exception ex)
            {
                logger.Error(" Error al iniciar servicio,detalle:" + ex.Message + ex.InnerException + ex.StackTrace);
                EventLog.WriteEntry(ex.Message + ex.InnerException + ex.StackTrace);
            }
        }