问题一:
windows service 启动时需要用死循环来控制程序,如果不开启异步,死循环会导致windows sevice 程序无法启动,代码情况如下
protected override void OnStart(string[] args) { writeLog(string.Format("{0}-已启动", base.ServiceName),startPath); Task.Factory.StartNew(SendEmail, cancelTokenSource.Token); }