次の方法で共有


CeAcquireRwLock (Compact 2013)

3/28/2014

CeAcquireRwLock attempts to acquire either shared or exclusive access to a reader/writer lock.

Syntax

BOOL
    CeAcquireRwLock(
    __in HRWLOCK hLock,
    __in CERW_TYPE typeLock,
    __in DWORD dwTimeout
    );

Parameters

  • hLock
    [in] Handle to the reader/writer lock created by a call to CeCreateRwLock
  • typeLock
    [in] Type of requested lock access. Specify CERW_TYPE_SHARED to request shared (read-only) lock access, or CERW_TYPE_EXCLUSIVE to request exclusive (read/write) lock access.
  • dwTimeout
    [in] Time, in milliseconds, to wait for the lock to become available if access cannot be granted immediately. Setting dwTimeout to zero forces CeAcquireRwLock to return immediately whether the requested access is granted or not.

Return Value

TRUE indicates the calling thread has been successfully granted the desired access to the lock specified in hLock. FALSE indicates lock access could not be granted in the specified timeout. To get extended error information, call GetLastError.

Remarks

If the lock is invalid, GetLastError will return ERROR_INVALID_PARAMETER.

If dwTimeout is set to a value greater than zero, the calling thread will block for the specified amount of time. If a timeout occurs acquiring a lock with either shared or exclusive access, GetLastError will return WAIT_TIMEOUT.

However, if CeAcquireRwLock is called recursively to request exclusive access to a lock, a deadlock condition may occur. In this case, CeAcquireRwLock will return FALSE immediately to prevent deadlock, and GetLastError will return ERROR_LOCK_VIOLATION

Locks acquired by calling CeAcquireRwLock should be released by calling CeReleaseRwLock.

Requirements

Header

Cerwlock.h

Library

coredll.lib

See Also

Reference

Synchronization Functions
Synchronization Enumerations
CeCreateRwLock
CeReleaseRwLock