Good way to run recurring background task in WCF?

旧城冷巷雨未停 提交于 2019-12-13 14:46:21

问题


I have a WCF solution that runs under IIS. Some of the data I need to give back to clients comes from a third party website that we will need to poll frequently to get any new data.

Would it be a bad practice to create a Timer in the Application_Start() method to run a recurring background Task for this purpose? And if it's not a good idea, then what do you recommend?


回答1:


No it's not a good idea. The reason for this is that IIS can and will unload your app domain for many different reasons. When this happens there's no warning, and the app domain may stay unloaded for a long time, even until a request comes in to "wake it up".

To achieve what you want you should offline this polling process and make it durable across IIS appdomain unload/load cycles. There are a few different techniques for this, but I would recommend hangfire.



来源:https://stackoverflow.com/questions/29354953/good-way-to-run-recurring-background-task-in-wcf

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