The entry point to Semaphore properties and methods.
Sets or determines whether or not the semaphore is global.
object.Global[=Sem As Boolean]
Boolean.
Read/write.
Sem is an optional parameter that specifies a global (TRUE) or local (FALSE) semaphore.
This example sets the semaphore as Global.
set Sem = CreateObject("ucx:Semaphore")
print(Sem.Global)
Sem.Global=True
Sets or returns the semaphore ID.
object.ID[=SemID As Long]
Long.
Read/write.
SemID is an optional parameter. For a local semaphore, you can use it to set the Semaphore ID to 1-5. For a global semaphore, it is read-only.
This example returns the semaphore ID.
set Sem = CreateObject("ucx:Semaphore")
Sem.global=True
sem.name="YY"
sem.lock(10)
print("Semaphore ID is: " &sem.ID)
sem.unlock
Determines whether or not the semaphore is locked.
object.Locked
Boolean.
Read-only.
This property returns TRUE if the semaphore is locked; otherwise; FALSE.
This example returns TRUE if the semaphore is locked; otherwise, FALSE.
set Sem = CreateObject("ucx:Semaphore")
Sem.global=True
sem.name="YY"
sem.lock(10)
if sem.Locked = True Then
print "True"
else
print "False"
end if
sem.Unlock
Sets or returns the semaphore name.
object.Name[=Name As String]
String.
Read/write.
Name is an optional parameter that represents the new name of the semaphore.
This example returns the name of the semaphore.
set sem = CreateObject("ucx:Semaphore")
Sem.global=True
sem.name="YY"
sem.lock(10)
print("Semaphore name is: " &sem.Name)
sem.unlock
Locks a semaphore.
object.Lock(
[Timeout As Integer])
Optional. The time, in milliseconds, to lock the semaphore. This parameter is required for a global semaphore, but not for a local semaphore.
Boolean. Returns TRUE if the semaphore is successfully locked; otherwise, FALSE.
This example locks the YY semaphore in 1000 milliseconds.
set sem = CreateObject("ucx:Semaphore")
Sem.global=True
sem.name="YY"
sem.lock(10)
if (Sem.Global=True) Then
Sem.Lock(1000)
print "Global semaphore is locked"
else
Sem.Lock()
print "Local semaphore is locked"
end if
Sem.Unlock()
Unlocks a semaphore.
object.Unlock()
None.
Boolean. Returns TRUE if the semaphore is successfully unlocked; otherwise, FALSE.
This example unlocks the YY semaphore.
set sem = CreateObject("ucx:Semaphore")
Sem.global=True
sem.name="YY"
sem.lock(10)
if (Sem.Global=True) Then
Sem.Lock(1000)
print "Global semaphore is locked"
else
Sem.Lock()
print "Local semaphore is locked"
end if
Sem.Unlock()