Lock.ScopedLock Method

Calls Enter on the underlying TCriticalSection and returns an interface reference that will call Leave once it goes out of scope.

Namespace: Spring
 function ScopedLock: IInterface;

Return Value

Type: IInterface


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.