-
Notifications
You must be signed in to change notification settings - Fork 40
Description
I have a service which is supposed to accumulate data within its lifetime and then flush these data to an external resource upon the end of an HTTP request.
Its lifetime should be restricted to one http request and that's why I use InRequestScope. But seems like it cannot give 100% guarantee that my service gets Disposeed upon the request end. Moreover, this approach would make my code too dependant on Ninject.
That's why I use HttpContext.Current.DisposeOnPipelineCompleted to guarantee what I need and be able to re-use my service in non-Ninject projects.
However, InRequestScope after some time fires Dispose meaning this method gets invoked twice for the same object which is not good.
I may introduce some locks and flags to avoid double execution but this is going to make my code dirty. Thus, my question: is there a way to ask Ninject not to Dispose some services?