Lock.ScopedLock Method
Definition
Calls Enter on the underlying TCriticalSection and returns an interface reference that will call Leave once it goes out of scope.
Delphi
function ScopedLock: IInterface
Returns
IInterface
Remarks
Use this to avoid the classic try/finally block but keep in mind that the scope will be the entire method this is used in unless you keep hold of the returned interface and explicitly set it to nil causing its destruction.