CSingleLock::Unlock

释放 CSingleLock拥有的同步对象。

BOOL Unlock( ); 
BOOL Unlock( 
   LONG lCount, 
   LPLONG lPrevCount = NULL  
);

参数

  • lCount
    访问数。版本。 必须大于 0。 如果指定的数量将导致对象的计数超过其最大值,不更改计数,函数返回 FALSE

  • lPrevCount
    指向变量接收同步对象以前的计数。 如果 NULL,前面的计数不返回。

返回值

非零,如果函数运行成功;否则为0。

备注

此函数由CSingleLock的析构函数调用。

如果您需要释放多信号量的访问计数,请使用 Unlock 的第二个窗体并指定访问的位数。版本。

示例

// m_Mutex is a data member (of type CMutex)
// of an existing class that implements the resource being shared.

// Relate the synchronization object (m_Mutex) with
// our CSingleLock object. 
CSingleLock singleLock(&m_Mutex);

// Attempt to lock the shared resource
if (singleLock.Lock(100))    // Wait 100 ms...
{
    // We were able to lock the resource;
    // we may now work with the data associated with the mutex...

    // Now that we are finished, unlock the resource for others.
    singleLock.Unlock();
}

要求

Header: afxmt.h

请参见

参考

CSingleLock Class

层次结构图