Topshelf的新位置,
http://github.com/Topshelf/Topshelf
已使用允许此行为的修补程序更新。
RunConfiguration cfg = RunnerConfigurator.New(x =>
{
x.AfterStoppingTheHost(h => { Console.WriteLine("AfterStop called invoked, services are stopping"); });
x.ConfigureService<TownCrier>(s =>
{
s.Named("tc");
s.HowToBuildService(name=> new TownCrier());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
// Running as the network service account
x.RunAsNetworkService();
x.SetDescription("Sample Topshelf Host");
x.SetDisplayName("Stuff");
x.SetServiceName("stuff");
});
Runner.Host(cfg, args);