|
-
November 6th, 2007, 04:03 PM
#1
putting critical section to work
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|