27

This question already has an answer here:

So i've read around that instead of calling a event directly with

if (SomeEvent != null)
   SomeEvent(this, null);

i should be doing

SomeEventHandler temp = SomeEvent;
if (temp != null)
    temp(this, null);

Why is this so? How does the second version become thread safe? What is the best practice?


  • Reading over the tentative, qualified answers here I get the sense that event handling in C# is tightly-coupled, error-prone, and not understood very well. - micahhoover

Linked


Related

Latest