using SMP.Message.Consumer; using Topshelf; class Program { static void Main(string[] args) { HostFactory.Run(x => { x.Service(s => { s.ConstructUsing(name => new TaskRunner()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.RunAsLocalSystem(); x.SetDescription("SMP消息服务"); x.SetDisplayName("SMPMessageService"); x.SetServiceName("SMPMessageService"); }); Console.ReadKey(); } }