CComCritSecLock Class

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see CComCritSecLock Class on docs.microsoft.com. This class provides methods for locking and unlocking a critical section object.

template<class TLock> class CComCritSecLock

Parameters

TLock
The object to be locked and unlocked.

Public Constructors

NameDescription
CComCritSecLock::CComCritSecLockThe constructor.
CComCritSecLock::~CComCritSecLockThe destructor.

Public Methods

NameDescription
CComCritSecLock::LockCall this method to lock the critical section object.
CComCritSecLock::UnlockCall this method to unlock the critical section object.

Use this class to lock and unlock objects in a safer way than with the CComCriticalSection Class or CComAutoCriticalSection Class.

Header: atlbase.h

The constructor.

CComCritSecLock(TLock& cs, bool bInitialLock = true);

Parameters

cs
The critical section object.

bInitialLock
The initial lock state: true means locked.

Remarks

Initializes the critical section object.

The destructor.

~CComCritSecLock() throw();

Remarks

Unlocks the critical section object.

Call this method to lock the critical section object.

HRESULT Lock() throw();

Return Value

Returns S_OK if the object has successfully been locked, or an error HRESULT on failure.

Remarks

If the object is already locked, an ASSERT error will occur in debug builds.

Call this method to unlock the critical section object.

void Unlock() throw();

Remarks

If the object is already unlocked, an ASSERT error will occur in debug builds.

CComCriticalSection Class
CComAutoCriticalSection Class

Show: