开发者

IoC and thread singletons

开发者 https://www.devze.com 2023-02-01 23:25 出处:网络
Several different IoC containers have support for Thread Singletons. How do the frameworks know when a thread goes out of scope?

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

精彩评论

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

关注公众号