Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem with static and std::map Pin
Diddy4-Feb-04 4:07
Diddy4-Feb-04 4:07 
GeneralRe: Problem with static and std::map Pin
inter8ection4-Feb-04 4:40
inter8ection4-Feb-04 4:40 
GeneralRe: Problem with static and std::map Pin
Diddy4-Feb-04 4:47
Diddy4-Feb-04 4:47 
GeneralProblem with Kernel Object Security Pin
particle2k4-Feb-04 1:15
particle2k4-Feb-04 1:15 
GeneralRe: Problem with Kernel Object Security Pin
Alexander M.,4-Feb-04 3:09
Alexander M.,4-Feb-04 3:09 
GeneralRe: Problem with Kernel Object Security Pin
particle2k4-Feb-04 3:31
particle2k4-Feb-04 3:31 
GeneralMultithreading in C++ Pin
TV4-Feb-04 0:11
TV4-Feb-04 0:11 
GeneralRe: Multithreading in C++ Pin
Diddy4-Feb-04 2:11
Diddy4-Feb-04 2:11 
First of all, you are not _really_ using CSingleLock correctly.

The point of CSingleLock is to basically aid in cleaning up your critical section if your code throws an exception, or returns take this:

fun()
{
CCriticalSection section;
section.lock()
.
.
.
if (ladeda)
return false;

section.unlock();
}

here, if the "if (ladeda)" condition was true and you returned, you would be left with a locked CS. - using it this way you have to remeber to unlcok the CS before you return, it makes it harder to use exceptions or to have multiple return points in a function. CSingleLock overcomes that by locking in the constructor and unlocking in the destuctor, so by declaring one on the stack, your CS will automatically be unlocked when that stack unwinds - where ever you may be.

You use CSingleLock to overcome the problem like this:

fun()
{
CCriticalSection section;
CSingleLock lock(§ion, TRUE).
.
.
if (ladeda)
return false;

// no need to unlock section, done by ~CSingleLock
}


In other words, remove the explicate calls to singleLock.Lock(); and singleLock.Unlock(); in your code, and change the decliaration to be CSingleLock singleLock(critSectionPosition, TRUE); - this causes the constructor to call Lock for you.

As for your actual problem, well, it depends on what type your critSectionPosition data member is... You haven't included that bit Blush | :O ) You have to pass a pointer to a CS (or any other sync object) to CSingleObject, the assert is telling you your what you are passing is not of type CSyncObject - ie your not passing a CCritcalSection* which dervices from CSyncObject.

If you put up the critSectionPosition data type, I should be able to tell you.
GeneralRe: Multithreading in C++ Pin
TV4-Feb-04 3:58
TV4-Feb-04 3:58 
GeneralRe: Multithreading in C++ Pin
Diddy4-Feb-04 4:30
Diddy4-Feb-04 4:30 
QuestionHow do i get handle to window in IE Pin
User 2155973-Feb-04 23:41
User 2155973-Feb-04 23:41 
AnswerRe: How do i get handle to window in IE Pin
Amr Abdel-Mohsen4-Feb-04 9:20
Amr Abdel-Mohsen4-Feb-04 9:20 
Generalprinting a html file Pin
Member 5281553-Feb-04 22:53
Member 5281553-Feb-04 22:53 
GeneralRe: printing a html file Pin
Anonymous4-Feb-04 11:22
Anonymous4-Feb-04 11:22 
Generalsingleton problem Pin
yccheok3-Feb-04 22:19
yccheok3-Feb-04 22:19 
GeneralRe: singleton problem Pin
Cristian Teodorescu3-Feb-04 23:01
Cristian Teodorescu3-Feb-04 23:01 
QuestionWhy slower draws on Screen with HW Accel. set to FULL? Pin
uus993-Feb-04 21:46
uus993-Feb-04 21:46 
Generallib/dll file question Pin
bryce3-Feb-04 21:45
bryce3-Feb-04 21:45 
GeneralRe: lib/dll file question Pin
bryce3-Feb-04 22:15
bryce3-Feb-04 22:15 
GeneralRe: lib/dll file question Pin
goozmo3-Feb-04 22:37
goozmo3-Feb-04 22:37 
GeneralDatabase environment Pin
JensB3-Feb-04 21:38
JensB3-Feb-04 21:38 
GeneralRe: Database environment Pin
Roger Wright4-Feb-04 4:00
professionalRoger Wright4-Feb-04 4:00 
GeneralCan't not read string correctly from resource Pin
Paul.Huang3-Feb-04 20:26
Paul.Huang3-Feb-04 20:26 
GeneralRe: Can't not read string correctly from resource Pin
Diddy4-Feb-04 2:23
Diddy4-Feb-04 2:23 
GeneralRe: Can't not read string correctly from resource Pin
Paul.Huang4-Feb-04 14:52
Paul.Huang4-Feb-04 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.