VS2010如何一步步開發新增Windows服務(Windows service)及服務安裝啟動
阿新 • • 發佈:2019-01-10
partial class MainService : ServiceBase { private CETCBackServer cetcBackServer; private IContainer components = null; private ILog log = LogManager.GetLogger("CETCService"); public CETCService() { this.InitializeComponent(); } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { this.components = new Container(); base.ServiceName = "Service1"; } protected override void OnStart(string[] args) { this.cetcBackServer = new CETCBackServer(); } protected override void OnStop() { this.cetcBackServer.Dispose(); this.log.Info("停止服務"); } }