Quartz.NET总结(八)如何根据自己需要配置Topshelf 服务
2020-01-11 11:26
前面讲了如何使用Topshelf 快速开发windows服务, 不清楚的可以看之前的这篇文章:
HostFactory.Run(x => //1 { x.Service<TownCrier>(s => //2 { s.ConstructUsing(name => new TownCrier()); //配置一个完全定制的服务,对Topshelf没有依赖关系。常用的方式。 //the start and stop methods for the service s.WhenStarted(tc => tc.Start()); //4 s.WhenStopped(tc => tc.Stop()); //5 }); x.RunAsLocalSystem(); // 服务使用NETWORK_SERVICE内置帐户运行。身份标识,有好几种方式,如:x.RunAs("username", "password"); x.RunAsPrompt(); x.RunAsNetworkService(); 等 x.SetDescription("Sample Topshelf Host服务的描述"); //安装服务后,服务的描述 x.SetDisplayName("Stuff显示名称"); //显示名称 x.SetServiceName("Stuff服务名称"); //服务名称 });