TT (Tom Tempelaere) <"=?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?=" <_N_
0SPA|/\|t*******@hotmail.com|/\|APS0_N_>> wrote:
I'm reading the C# coding standard and I don't understand the following item (38):
38. With delegates as class members:
a) Copy a delegate to a local variable before publishing to avoid
concurrency race condition.
What is the reasoning here?
You normally need to do a test for the delegate being null before
invoking it. If you don't copy it to a local variable first, you could
end up testing it for null, then trying to invoke it, with something
else setting it to null between the test and the invocation.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too