Reputation: 661
My understanding is that the HostingEnvironment.QueueBackgroundWorkItem API was introduced so one could spawn a new thread in an Asp.net application, and this new thread wouldn't immediately terminate when the AppDomain is signaled to shutdown (for example, if someone does an IIS app pool recycle). Instead, it will wait some time to try to complete it's work normally before shutting down the AppDomain. Can I use this same API in a WCF application? If not, is there equivalent functionality in the WCF stack? Or can this not be done reliably in WCF, and requires some kind of persistent queue?
Upvotes: 3
Views: 537
Reputation: 2721
According to the MSDN documentation, it will only work with ASP.NET. The reference source shows that an InvalidOperationException
is thrown when calling QueueBackgroundWorkItem()
without an ASP.NET environment. I can confirm that the exception occurs when attempting to use this feature in WCF.
Upvotes: 2