protected override void OnStart(string[] args) { TestService.Start(); WCFHost host = new WCFHost(); host.open(); Log4netHelper.Debug("OnStart", "服务开始"); }
protected override void OnCustomCommand(int command) { try { Log4netHelper.Debug(GetType().FullName, "command=" + command); } catch (Exception ex) { } }
protected override void OnPause() { try { Log4netHelper.Debug(GetType().FullName, "OnPause"); } catch (Exception ex) { } }
static void RunCommandFile(string cmd) { try { string cmdfile = "service.cmd"; File.WriteAllText(cmdfile, cmd); Process.Start(cmdfile); Log4netHelper.Debug("RunCommandFile", "服务安装成功"); } catch (Exception ex) { Log4netHelper.Error("RunCommandFile", ex.Message, ex); } }
protected override void OnStop() { Log4netHelper.Debug("OnStop", "服务停止"); }