TopShelf简介 个人理解:开源、跨平台的服务框架。提供一种方式以控制台编写windows服务,与windows服务相比,目前只发现便于调试。 官网网站:http://docs.topshelf-project.com/en/latest/index.htmlTo ...
个人理解:开源、跨平台的服务框架。提供一种方式以控制台编写get='_blank'>windows服务,与windows服务相比,目前只发现便于调试。
官网网站:http://docs.topshelf-project.com/en/latest/index.html
借用topshelf官网用例:
public class TownCrier { readonly Timer timer; public TownCrier() { timer = new Timer(1000) { AutoReset = true }; timer.Elapsed += (sender, eventArgs) => Console.WriteLine("It is {0} and all is well", DateTime.Now); } public void Start() { timer.Start(); } public void Stop() { timer.Stop(); } } public class Program { public static void Main(string[] args) { HostFactory.Run(x => { x.Service<TownCrier>(s => { s.ConstructUsing(name => new TownCrier()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.RunAsLocalSystem(); x.SetDescription("sample Topshelf Host"); x.SetDisplayName("stuff"); x.SetServiceName("Stuff"); }); } }
原标题:Topself
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。