I am reviewing the code written by a consultant, and when dozens of red flags have already appeared, I cannot wrap around the following snippet:
private void foo() { if (InvokeRequired) { lock (new object()) { if (m_bar!= null) Invoke(new fooDelegate(foo), new object[] { }); } } else { if(OnBazChanged != null) OnBazChanged(); } }
What does lock (new object ()) do here? It should not have any effect, since it always blocks another object, but such a lock is preserved in all code, even in parts that are not copied and pasted. Is this some special case in C # that compiled to something I donβt know about, or asked the programmer to accept some piece of cargo that once worked?
c # thread-safety locking
lbruder Aug 20 2018-12-12T00: 00Z
source share