Wile
Junior Contributor
I'll add a tip that can be usefull while debugging. While running your application, under the Debug -> Windows a lot of items are available. One of them is Threads (default key combo: ctrl + alt + H).
Open this window.
When your program is paused (e.g. on a breakpoint or just stepping through some code), you can view all the active threads in your application in that window. If the Location of a thread is somewhere in your code, you can double click on that line, and the debugger will show the exact location of where that thread is at that moment, that way you can view what all the different threads are doing.
In most cases this is the easiest way to spot a deadlock or a situation like it seems to be in the code you posted above. When debugging the current code you should see 1 thread inside the loop, and other threads in the same function, but waiting for the SyncLock.
Good luck .
Open this window.
When your program is paused (e.g. on a breakpoint or just stepping through some code), you can view all the active threads in your application in that window. If the Location of a thread is somewhere in your code, you can double click on that line, and the debugger will show the exact location of where that thread is at that moment, that way you can view what all the different threads are doing.
In most cases this is the easiest way to spot a deadlock or a situation like it seems to be in the code you posted above. When debugging the current code you should see 1 thread inside the loop, and other threads in the same function, but waiting for the SyncLock.
Good luck .