Error!
Success!

Using Interlocked to allow a single thread access to a resoure.

0
kicks

Using Interlocked to allow a single thread access to a resoure.  (Unpublished)

Using SyncLock (or lock in C#) to block all threads accessing a block of code can be overkill. SyncLock requires that all CPU instructions be cleared from the registers so that thread synchronization can be performed safely and it also requires a lot of management by the .NET threading libraries. In certain situation where multiple threads are running, you may require that just a single thread execute a piece of code at any one time. I've used this in situations where multiple threads are there for performance reasons but only 1 thread at a time should say clear down/refresh cache entries, but any of those threads could do the work.


Kicked By:
Drop Kicked By: