Race condition in C # static constructor

I discussed with a friend who claims that a static constructor can give way to a race condition, since a static constructor could be called several times. It seems that this can only happen in multi-threaded environments with a large volume. Is it possible?

I could not find the documentation to prove that he was wrong. Does anyone know about this?

Thank!

+5
source share
2 answers

The static constructor is called only once for the AppDomain.
ECMA-335 declares that the CLI warrants that:

"The type initializer must be executed exactly once for any given type, unless explicitly called by the user code."

#.

, .
. :
https://msmvps.com/blogs/jon_skeet/archive/2012/04/07/type-initializer-circular-dependencies.aspx)

+3

?

. CLR .

#. , 3.1 :

.

+12

All Articles