From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


Supported for all project types and targets.

Call Signal to obtain a lock on a resource. Once you are done with the shared resource, the thread should call Release to increment the internal counter.


Every time thread calls Signal, the Semaphore decrements the counter. If the counter is less than zero, it suspends the thread.

When you obtain a lock, you can use the resource without fear that another thread will try to use it simultaneously. If the call succeeds, this function returns immediately and you code continues to execute. If the lock is not available, then the thread that called this method will wait until the lock becomes available. When the call returns, you will have the lock, but you may have to wait until the lock becomes available. When you are finished using the resource, call the Release method to give it back to the Semaphore.