在.NET中启动Windows背景服务的参数
我正在使用.NET的backgroundService
摘要类制作Windows服务(类似于 Microsoft撰写的本教程),但我似乎无法弄清楚如何使用Windows Services应用程序开始使用Windows Services应用程序传递给服务的参数。有人可以告诉我如何获得我在那里经历的论点还是我应该做什么?
I am making a Windows Service using .NET's BackgroundService
abstract class (similar to the one in this tutorial by Microsoft) but I can't seem to figure out how to get start arguments passed to the service using the Windows Services app. Can someone tell me how to get the arguments I pass in there or what I should be doing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须从
main
:您的工作人员对您的服务有一个依赖性:
EG使用此简单服务:
<
a href =“ https://i.sstatic.net/ qm3si.png“ rel =“ noreferrer”>
i.sstatic.net/umk9b.png“ rel =“ noreferrer”>
You have to pass through the args from
Main
:Your worker then has a dependency on your service:
e.g. with this simple Service:
Results:
创建一个从
servicebase
派生的类以接收参数并实现ihostlifetime
。用
useWindowsService
替换此类。Create a class derived from
ServiceBase
to receive parameters and implementIHostLifetime
.Replace this class with
UseWindowsService
.