CComCritSecLock Class
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at CComCritSecLock Class.
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
| Name | Description |
|---|---|
| CComCritSecLock::CComCritSecLock | The constructor. |
| CComCritSecLock::~CComCritSecLock | The destructor. |
Public Methods
| Name | Description |
|---|---|
| CComCritSecLock::Lock | Call this method to lock the critical section object. |
| CComCritSecLock::Unlock | Call 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.