简体   繁体   English

WCF单例托管在Windows服务中。如何在没有先用客户端“触摸”服务的情况下自动启动WCF

[英]WCF singleton hosted in windows service. How to auto start WCF without first “touching” the service with client

I have a WCF service hosted in windows service. 我在Windows服务中托管了WCF服务。

Currently when the windows service starts i have to "touch" the WCF service with a client to run some long running code in WCF service. 目前,当Windows服务启动时,我必须与客户端“触摸”WCF服务,以在WCF服务中运行一些长时间运行的代码。

Is it somehow possible to auto start the long running code in WCF service without calling the service with a client? 是否有可能在不使用客户端调用服务的情况下在WCF服务中自动启动长时间运行的代码?

IIS 7.5 is not an option. IIS 7.5不是一个选项。

Yes, use OnStart method for this. 是的,使用OnStart方法。 It will be triggered once the Windows service gets a START command from OS. 一旦Windows服务从OS获得START命令,它就会被触发。

Put your "touch" code (logic) there. 把你的“触摸”代码(逻辑)放在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM