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

Deactivate instances in reverse order they were activated #364

Open
dombrovsky opened this issue Nov 13, 2019 · 1 comment
Open

Deactivate instances in reverse order they were activated #364

dombrovsky opened this issue Nov 13, 2019 · 1 comment

Comments

@dombrovsky
Copy link

Imagine we have two classes A and B, both implement IDisposable and A is a dependency for B. Instance of A would be created first. However when kernel disposed, the order in which IDisposable.Dispose() is called for both of them is not defined. This could lead to the situation when dependency become disposed earlier than dependent instances.
The suggestion is to ensure that Dispose on tracked instances is called in reverse order they were created.

@lsoft
Copy link

lsoft commented Mar 1, 2021

@dombrovsky what's about the situation with 2 IDisposable decorators with conditional bindings? A0 : IA A1 : IA, IA : IDisposable. It is very difficult (or even impossible?) for the container to determine the order of disposing without making resolution process slower (I guess; I'm not a maintainer). We love Ninject not for speed of course ;) but I would prefer a better performance but not auto-dispose.

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

2 participants