Esempio n. 1
0
    protected override void OnStart(string[] args)
    {
        try {
            //start any threads or http listeners etc
            //var process = Process.GetProcessesByName(InstallServiceName).FirstOrDefault();
            //if (null != process && Process.GetCurrentProcess().Id != process.Id) process.Kill();
            running = true;
            inst.Control(running);
            new Thread(delegate() {
                inst.Execute(Debug);
                //new ServiceEntry().Execute(Debug);



                //var client = new UdpClient();
                while (running)
                {
                    Thread.Sleep(1);
                    //    Thread.Sleep(1000);
                    //    client.Send(Encoding.UTF8.GetBytes("hello"), 5, "192.168.1.186", 31120);
                }
            })
            {
                IsBackground = true
            }.Start();
        } catch (Exception ex) {
            EventLog.WriteEntry(ex.Message + ex.StackTrace);
        }
    }