我正在使用Topshelf創建一個Windows服務(ServiceClass),我正在考慮使用WhenCustomCommandReceived發送自定義命令。如何使用WhenCustomCommandReceived設置Topshelf?
HostFactory.Run(x =>
{
x.EnablePauseAndContinue();
x.Service<ServiceClass>(s =>
{
s.ConstructUsing(name => new ServiceClass(path));
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
s.WhenPaused(tc => tc.Pause());
s.WhenContinued(tc => tc.Resume());
s.WhenCustomCommandReceived(tc => tc.ExecuteCustomCommand());
});
x.RunAsLocalSystem();
x.SetDescription("Service Name");
x.SetDisplayName("Service Name");
x.SetServiceName("ServiceName");
x.StartAutomatically();
});
但是,我越來越對WhenCustomCommandReceived行錯誤:
委託 '行動<服務類,HostControl,int>的' 不拿1個參數
簽名是
ServiceConfigurator<ServiceClass>.WhenCustomCommandReceived(Action<ServiceClass, HostControl, int> customCommandReceived)
我已經有在我的ServiceClass中啓動,停止,暫停的方法:public void Start()等等。任何人都可以在ho的正確方向指向我w設置操作?謝謝!
謝謝雅各布!解決了我的問題。今天學到了新東西。 –