共用方式為


CSingleLock::Unlock

釋放 CSingleLock擁有的同步物件。

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

參數

  • lCount
    存取的數字要釋放的。 必須大於 0。 如果指定的數量會導致物件的計數超出其上限時,不會變更計數和函式傳回

  • lPrevCount
    out 接收同步物件的上一個計數的變數的點。 如果 NULL,上一個計數不會傳回。

傳回值

如果不是零,則函式成功,則為 0。

備註

這個函式會被 CSingleLock 的解構函式 (Destructor) 呼叫。

如果您需要釋放超過號誌的存取計數,請使用 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 類別

階層架構圖表