TSGetExclusiveSemaphore()

Syntax

TSGetExclusiveSemaphore(semaphore, timeout)

Description

This command allows you to ask for access to a semaphore. It works for both simple semaphores and the exclusive section of complex semaphores. For simple semaphores, this command is exactly the same as using TSGetSemaphore(). If the semaphore is available then your application will get it (decreasing availability by one) and continue. If the semaphore is not available, your thread will be blocked until the semaphore becomes available, or until the timeout occurs. If the timeout occurs, you do NOT have access to the semaphore.

Paramaters:
semaphore.l - The handle of the semaphore which was created with TSCreateSemaphore()
timeout.l - The maximum length of time to wait for access to the semaphore before giving up. This value is specified in milliseconds. Two special values of interest are 0 which means just to check and give up if the semaphore is not available immediately and #INFINITE which will make your wait forever if it never gets the semaphore.

Return value:
This command returns a value which shows if you have access to the semaphore or not. If you have access then the value will be true (any non-zero value) and if you do not have access then the value will be false (zero).

Example:


See also:

Supported OS

Windows

ThreadSync - Index