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();
}

요구 사항

헤더: afxmt.h

참고 항목

참조

CSingleLock 클래스

계층 구조 차트