I'm reviewing some code written by a consultant, and while dozens of red flags have already popped up, I can't wrap my head 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 is lock(new object()) doing here? Should have no effect whatsoever as it's always locking on another object, but this kind of locking is persistent throughout the code, even in non-copy-and-pasted parts. Is this some special case in the C# language that is compiled to something I don't know about, or has the programmer simply adopted some cargo cult that happened to work some time ago?