I'm looking to leverage the QueueBackgroundWorkItem feature in available in .NET 4.5.2+ on our ASP.NET Web API application, however, I consistently am getting "Invalid Operation" exceptions when attempting to put something into the queue. I believe this may be related to the fact that our app is self-hosted using OWIN and the queueing of the work item is an IIS only feature? If this is true, just wanted to see if there would be any suggestions at all in regards to queueing background work from an owin-self hosted API.
3
votes
2 Answers
3
votes
2
votes
I had this issue in a test environment answered here.
In the end, I used Hangfire and its fire and forget code
//Fire-and-forget tasks
// Static methods are for demo purposes
BackgroundJob.Enqueue(
() => Console.WriteLine("Simple!"));