Xojo.Threading.CriticalSection.Enter

From Xojo Documentation

Revision as of 18:29, 29 August 2018 by PLefebvre (talk | contribs) (Created page with "{{MethodBox | name = Enter | ownertype = class | scope = public | parameters = | owner = Xojo.Threading.CriticalSection }} {{Description | text = Attempts to get a lock o...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Method

Xojo.Threading.CriticalSection.Enter()

Supported for all project types and targets.

Attempts to get a lock on the resource managed by the CriticalSection.

Notes

When the call to Enter succeeds, it returns and your code has exclusive access to the protected resource. If the lock cannot be obtained immediately, Enter will block the current thread from continuing to run. It will wait for the resource to become available.

Enter differs from the Signal method of the Semaphore class in that it can be called multiple times from the currently executing thread. If the calling thread already owns the lock, the method returns immediately. This makes CriticalSections very useful for calling a method recursively.