So this is not my code and has been shortened to show behavior, but it gives very unexpected results.
I have two functions in the class and lock
object mylock = new object(); List<string> temp = new List<string>(); Func1(string) { lock(mylock) { temp.Add(string); } } Func2() { lock(mylock) { temp.ForEach(p => Func1(p)); } }
Now I know that this makes no sense, but when Func2 is called, should Func1 not hang? In our case, it is executed. Thanks.
Steve source share