My answer is more likely a comment for Thomas Levesque, but I cannot comment, so nothing happens here. I find this C # area a little ugly, as itβs possible to enter race conditions - that is, different threads can participate in the race, and you can enter the if using CheckedChanged != null
if (CheckedChanged == null) { CheckedChanged += (s, e) => { // code; } }
You must either block this code, but in many cases you will find that you are writing such code
//Invoke SomeEvent if there are any handlers attached to it. if(SomeEvent != null) SomeEvent();
But SomeEvent can be zeroed out in the process, so it would be safer to write something like this
SomeEVentHandler handler = SomeEvent; if (handler != null) handler();
... just be more secure.
Gleno source share