How can I run a WCF service constructor once for all clients when it's InstanceContextMode is set to PerSession?

旧街凉风 提交于 2019-12-07 05:46:26

Why not run this operation just before you host the WCF Service in your windows service so it can be ready as soon as the WCF Service goes online. You can get from the running thread an event that it is finished and then deploy the WCF Service.

You need to write a service behavior or an endpoint behaviour. In this behaviour call the function at first call from a client and set a variable to true and store it in some permament memory or file location. You may have a look at the following msdn article about Extending WCF

Use a static constuctor? It will be called once when(before) any action with that class is taken in your code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!