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 an instance of an object that implements IDisposable. Let's name it foo. When I use container.RegisterInstance<T>(foo)foo will, from then on, be owned by the container. When I call container.Dispose()foo will be disposed as well.
Is there a way to make sure foo outlives the container? Since it wasn't created by LightInject I also don't want LightInject to clean it up.
The text was updated successfully, but these errors were encountered:
roy-t
changed the title
How to register a IDisposable instance that should outlive the container?
How to register an IDisposable instance that should outlive the container?
Jun 15, 2024
Short question that I couldn't find in the docs.
I have an instance of an object that implements
IDisposable
. Let's name it foo. When I usecontainer.RegisterInstance<T>(foo)
foo will, from then on, be owned by the container. When I callcontainer.Dispose()
foo will be disposed as well.Is there a way to make sure foo outlives the container? Since it wasn't created by LightInject I also don't want LightInject to clean it up.
The text was updated successfully, but these errors were encountered: