views:

54

answers:

2

The Application static members are supposed to be thread safe:

The public static (Shared in Visual Basic) members of this type are thread safe. In addition, the FindResource and TryFindResource methods and the Properties and Resources properties are thread safe.1

How much can we trust that statement in a multithreaded environment when calling static member methods of System.Windows.Application?

Update:
It's all in reference to this question: http://stackoverflow.com/questions/2463822/threading-errors-with-application-loadcomponent-key-already-exists/2463866#2463866

I never thought I'd see a real bug in the library, but this must be the day for me... that question seems to show a genuine bug. Usually it's "user error," but this doesn't seem to be the case.

+2  A: 

This is the general pattern of the .Net framework and associated libraries. Static / Shared members are assumed to be thread safe unless otherwise marked. If you find a member that is not thread safe and is not marked as such in the documentation it is a bug (in either the documentation or implementation).

Therefore I think it's safe to rely on them being thread safe.

JaredPar
Yah, I think Kellls must have found a bug then: http://stackoverflow.com/questions/2463822/threading-errors-with-application-loadcomponent-key-already-exists/2463866#2463866
Lirik
@Lirik, in this case it does seem like there is a bug in one or the other. I followed up on that thread to see if anyone filed a bug yet or not. AFAIK, it's OK for that method to not be thread safe but if so the documentation should be updated.
JaredPar
+1  A: 

In general you should trust the documentation at first, but stop trusting it when things don't work as advertised.

In this case the documentation is wrong because of a bug in WPF. See this answer for details about the bug.

Ray Burns
That's why I asked it :)... I'm the first person that answered that question.
Lirik