简体   繁体   中英

WCF Service With Worker Threads

I have developed a WCF Service that upon request, will create a worker thread and begin a sometimes extensive process of working with large amounts of data.

I require both this processing ability and the RESTful abilities of WCF Services to be able to be used.

Example: Storing a Thread Globally, and being able to access it in the RESTful Call.

However, from my understanding, doing this in IIS is not advised and IIS will terminate long-running applications, and it is advised to run this as a Windows Service hosted WCF Service.

Yet, we rely on the ability to use Web Deploy / Publishing via Visual Studio and is integral to our development process.

How can I have the best of both worlds?

Windows Services still have the same fundamental problem because you eventually have to deploy new code or restart the server (or, god forbid, have a crash!). The service will need to shut down.

You can mostly control when this happens with a Windows Service which is a good thing. But fundamentally you have to have a concept for that should happen with your long-running work in such a situation.

I think a well-tuned IIS app has almost no disadvantages compared to a Windows Service. There is just no way to run long-running work without interruption.

Deal with that fact. For example by restarting work and wrapping it in a transaction so that arbitrary interruptions do not cause data corruption.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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