Reducing the Count on a Semaphore ObjectLast reviewed: December 16, 1996Article ID: Q94997 |
The information in this article applies to:
ReleaseSemaphore(), which increments the count of a given semaphore object by a specified amount, will not take a negative value. If, for some reason, you want to reduce the number of available semaphore "slots" to temporarily restrict or reduce access, you may loop calling WaitForSingleObject() with a zero timeout, counting the number of times it succeeds. When you no longer need to hold the semaphore slots, call ReleaseSemaphore() with the number of slots counted. Note that this method does not prevent other threads from taking a semaphore slot when your thread is looping.
|
Additional reference words: 3.10 3.50 3.51 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |