exit sub in SyncLock

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
 
J

Jon Skeet [C# MVP]

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

threading - Monitor.Wait/Pulse 12
Question about Synclock and exceptions 3
SyncLock documentation 9
Monitor.Pulse Methos 2
SyncLock and Array.SyncRoot and ReDim 2
Synclock 1
tcpclient problem 2
SyncLock 4

Top