Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I suppress disposing when using InRequestScope? #42

Open
DmitrySenin opened this issue Oct 19, 2019 · 0 comments
Open

Can I suppress disposing when using InRequestScope? #42

DmitrySenin opened this issue Oct 19, 2019 · 0 comments

Comments

@DmitrySenin
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant