Reputation: 71198
I have a class like this:
public FooRepo : IFooRepo
{
public FooRepo(IDbContextFactory factory)
{
context = factory.GetContext();
}
}
In my app I register everything with LifeStyle.PerWebRequest
,
but now I need to call one Method which uses this IFooRepo
like this (because it's gonna take about an hour):
{
...
ThreadPool.QueueUserWorkItem(s => RequestReport(number));
...
}
private void RequestReport(int number)
{
// IFooRepo needed here
}
the problem is that I need this IFooRepo
with PerWebRequest lifestyle most of the time, and I needed here in the thread also to stay alive, also it has a dependency IDbContextFactory
which I don't know if I need to register it also in a different way
Upvotes: 0
Views: 331
Reputation: 27374
well then register your FooRepo
twice and setup service override for whoever uses in on the ThreadPool
to use the other component. Easy.
Upvotes: 2