Using Interlocked to allow a single thread access to a resoure.(lysaghtn.weebly.com)
submitted by
bigtoe(25) 3 years, 11 months ago
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.
|category: VB.NET
|Views: 18
tags:
VB.NET another
Everyones tags:
Your Tags: