You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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
Dispose
ed 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 firesDispose
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?The text was updated successfully, but these errors were encountered: