开发者

Prism Container Resolve Thread Safe

开发者 https://www.devze.com 2023-04-01 10:42 出处:网络
Is it thread safe if i want to create an instance of some type via Prism container resolve method that was previously registered as singleton? Un开发者_开发百科fortunately i couldn\'t find any info on

Is it thread safe if i want to create an instance of some type via Prism container resolve method that was previously registered as singleton? Un开发者_开发百科fortunately i couldn't find any info on this.


It depends on what you mean by thread-safe, and depending on the answer to that, what implementation of ServiceLocator you are using.

Both MEF and Unity containers are thread-safe in the sense that Resolve can be called independently from multiple threads for the same type. Theoretically you could have some other kind of ServiceLocator which was not thread-safe in this respect, but I would be surprised to find one, because it would make thread synchronization across a Prism app a real chore.

What may not be thread-safe is the actual object that is returned from the container. For instance, if you registered a Dictionary object and asked for that back, there is nothing magical about ServiceLocator that would make the Dictionary's operations thread safe.

0

精彩评论

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

关注公众号