Hey guys - I am trying to figure out how to get the default Funq IOC to work properly when executing requests outside of a normal HTTP request.
The situation is as follows
- During a standard HTTP request service call, we use Hangfire to enqueue a task to be run at a later time, even though we are using Hangfire, you can simulate this with ThreadPool.QueueUserWorkItem
- This callback is executed asynchronously on a new thread that is not in the HTTP pipeline
- I am following the examples on this page Executing a Service Internally to execute a request outside of the HTTP pipeline and it works fine however the main issue is that after executing the request, I can’t figure out how to get the IOC to dispose of the per requests objects that are created. I have setup a breakpoint in the IDispose method of one of our dependencies and it triggers after every single HTTP request, but I can’t for the life of me figure out how to get these “out of band” service calls to clean up. I figure it has something to do with the BasicRequest object that we are using, but can’t seem to figure it out.
Thanks in advance!