Provides an easy to use wrapper around TCriticalSection. It automatically initializes the TCriticalSection instance when required and destroys it when the Lock goes out of scope.
The Lock type exposes the following members.
Calls Enter on the underlying TCriticalSection. The first call also initializes the TCriticalSection instance.
Calls Leave on the underlying TCriticalSection. If no call to Enter has been made before it will raise an exception.
Calls Enter on the underlying TCriticalSection and returns an interface reference that will call Leave once it goes out of scope.