What the diffrence between this code:
::EnterCriticalSection( &m_CriticalSection );
//...
::LeaveCriticalSection( &m_CriticalSection );
and the code:
static CCriticalSection cs;
cs.Lock();
//...
cs.UnLock();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No difference practically.
CCriticalSectionis the only syntatic sugar of the former. It internally usesEnterCriticalSectionandLeaveCriticalSection!EnterCriticalSectionandLeaveCriticalSectionare low-level win32 APIs, whileCCriticalSectionis a MFC class which wraps these functionalities. It has a member data of typeCRITICAL_SECTIONwhich is used by the APIs.MSDN says,