Поделиться через


CSingleLock::CSingleLock

Создает объект CSingleLock.

explicit CSingleLock( 
   CSyncObject* pObject, 
   BOOL bInitialLock = FALSE  
);

Параметры

  • pObject
    Указывает на синхронизации объект быть к которому выполняется доступ. Не может быть NULL.

  • bInitialLock
    Указывает, является ли исходная попытаться получить доступ к указанный объект.

Заметки

Эта функция обычно называется из функции-члена доступа управляемого ресурса.

Пример

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

// Relate the synchronization object (m_CritSection) with
// our CSingleLock object. 
CSingleLock singleLock(&m_CritSection);
singleLock.Lock();  // Attempt to lock the shared resource
if (singleLock.IsLocked())  // Resource has been locked
{
   //...use the shared resource...

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

Требования

Header: afxmt.h

См. также

Ссылки

Класс CSingleLock

Диаграмма иерархии