Prism Container Resolve Thread Safe
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.
精彩评论