Skip to content

Can I suppress disposing when using InRequestScope? #42

@DmitrySenin

Description

@DmitrySenin

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions