Critical regions - how to?

Merrion

Well-known member
Joined
Sep 29, 2001
Messages
265
Location
Dublin, Ireland
User Rank
*Experts*
I have a single function that may be called by more than one thread at once but I want it to be a critical region i.e. if one thread is already in it make the other thread wait for the region to be freed before entering.

Any ideas?
 
Aha -put System.Runtime.CompilerServices.MethodImplAttribute attribute on the function signature and specify Synchronised...sweet.
 
If you ever need to have a smaller critical section where you want to lock access to one object, you can use the VB.NET Synclock block.
 
Back
Top