From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
This is a more friendly version of the Signal method that gives you a sneak-peek to determine whether there is a lock available.
If there is a lock available, you are granted the lock and TrySignal returns True. When you are finished with the resource, call Release to give it back to the Semaphore. If the lock is not available, you do not wait for it. Instead, TrySignal returns False to let you know. Do not attempt to use the resource after it returns False because you are likely to collide with another thread.
This example tests whether the lock is available before trying to use the resource.
// gets in here. One at a time!
If mLock.TrySignal Then
// Now that we're here, we can change the resource
SharedResource.Value = value
AccessText.Text = id.ToString
// And now that we've done something with the
// resource, we want to release our lock on it