开发者

IoC and thread singletons

Several different IoC containers have support for Thread Singletons.

How do the frameworks know when a thread goes out of scope?

For instance: If I use the Thread Pool to do something, how can the container know when to create and dispose a service? The thread can be used for 开发者_运维百科various of things and each task wants a new service, doesn't it?


In Autofac you'd do this manually by creating a scope around the thread entry point (can give example if required.) Maybe not so 'magic' as implicit thread scoping, but along the lines of what you're observing here, it is much easier to understand/test/debug.

IMHO :)

Nick

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜