Sorry, the get property should return "strMyField_" and not "strMyFieldId_" as it does. Just a typo...
-----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Eddie Lascu Sent: Thursday, August 10, 2006 5:25 PM To: [email protected] Subject: [ADVANCED-DOTNET] Multithread-safe classes I want to make my class multithread safe. What's the effect of writing something like this: public sealed class MyClass { public MyClass(string strValue) { strMyField_ = strValue; } public string MyField { get { lock(this) { return strMyFieldId_; } } } string strMyField_; } I know "lock" injects the "finally" block into the CIL, but is that executed if the return is before? =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
