dummy question about synclock and try...catch

  • Thread starter Thread starter buu
  • Start date Start date
B

buu

If I have a code like:


TRY
SYNCLOCK Object1
//some code
END SYNCLOCK
CATCH
END TRY


If an error occurs in a part "some code", will Object1 be released from
synclock or not?
shoul the code look like this?:

SYNCLOCK Object1
TRY
//some code
CATCH
END TRY
END SYNCLOCK
 
buu said:
If I have a code like:


TRY
SYNCLOCK Object1
//some code
END SYNCLOCK
CATCH
END TRY


If an error occurs in a part "some code", will Object1 be released from
synclock or not?
shoul the code look like this?:

SYNCLOCK Object1
TRY
//some code
CATCH
END TRY
END SYNCLOCK

SyncLock (and lock in C#) automatically have a try/finally block, so
the lock will always be released.
 
Back
Top