Reputation: 26909
I've inherited a multi-threaded data processing system that uses AutoFac for Dependency Injection.
Practically all dependencies are defined as InstancePerLifetimeScope()
, but there are no calls to container.BeginLifetimeScope()
to open a new scope.
What behaviour should I expect in this situation? I'm guessing one of the following:
The system is essentially a multi-threaded Windows Service; therefore no HTTP Requests or associated scopes.
Upvotes: 2
Views: 628
Reputation: 16192
When you use Autofac you create a IContainer
from a ContainerBuilder
. This IContainer
inherits from ILifetimeScope
and it is the global scope, the root of the scope tree, all other scopes will inherits from this scope.
When you resolve something from Autofac there is always a scope, if you don't create a child lifetime scope InstancePerLifetimeScope
is like SingleInstance
.
Upvotes: 3