user1068477
user1068477

Reputation:

Synclock in Module Constructor?

Coming from Java where Static Block are immediately called. In VB.NET (ASP.NET) a Module Constructor isn't called until the first method is called. So, this begs the question, if I'm performing initialization within my Module's constructor do I need to wrap it in a Synclock?

Upvotes: 0

Views: 193

Answers (1)

jmcilhinney
jmcilhinney

Reputation: 54427

Modules are a VB.NET programming nicety. Once compiled, they are the same as C# static classes, therefore a module constructor is the same as a C# static constructor. A C# static constructor is presumably exactly the same as a static block in Java. The documentation states that a C# static constructor is never executed more than once, so that would suggest that no synchronisation is necessary.

Upvotes: 0

Related Questions