exit sub in SyncLock

  • Thread starter Thread starter Perecli Manole
  • Start date Start date
P

Perecli Manole

Can an Exit Sub statement in a SyncLock block cause any problems with the
proper release of the locked resource or affect the Monitor's waiting queue
in any way?

Thanks
Perry
 
Perecli Manole said:
Can an Exit Sub statement in a SyncLock block cause any problems with the
proper release of the locked resource or affect the Monitor's waiting queue
in any way?

From the docs for SyncLock:

<quote>
Acquisition and Release. A SyncLock block behaves like a Try...Finally
construction in which the Try block acquires an exclusive lock on
lockobject and the Finally block releases it. Because of this, the
SyncLock block guarantees release of the lock, no matter how you exit
the block. This is true even in the case of an unhandled exception.
</quote>
 
Back
Top