I save a file which takes a long time, the time is not an issue right now. While it is being saved, if I press save again, now there are two save operations in progress and there is obviously an assertion.

I enclosed the save into critical section so the next time user press save, it will not execute that code but this mechanism does not work.
Code:
CSingleLock singleLock(&m_cricSection);

if (singleLock.IsLocked())
{
AfxMessageBox("locked");
return;
}
singleLock.Lock()
// ---- saving
singleLock.Unlock()
I tried this with CCriticalSection object as well as CEvent, does not work. It just executes the code everytime the control is here.

How can I make this critical section to work? thanks.