Back to the WFC main page
$Revision: 7 $
This class makes it easy to use a CCriticalSection
(an MFC class).
The critical section is entered in the contructor and left in the
destructor. This reduces coding mistakes when you have functions with
multiple returns. When the CCriticalSectionGuard
out of scope, the critical section is unlocked. It makes cleanup easy.
This ensures that the critical section will be exitted no matter where
you choose to exit the function.
CCriticalSectionGuard( CCriticalSection * section )
CCriticalSectionGuard( CCriticalSection& section )
Constructs the object. It calls the Lock() method of the
CCriticalSection. The destructor calls Unlock().
Copyright, 2000, Samuel R. Blackburn
void CMyClass::Method( void )
CCriticalSectionGuard guard( m_MyCriticialSection );
if ( ::GetTickCount() % 2 ) == 1 )
if ( ::GetTickCount() % 5 ) == 0 )
::KillTimer( m_WindowHandle, 1 );
$Workfile: CCriticalSectionGuard.cpp $
$Modtime: 1/04/00 5:09a $