Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Unable to set focus in CPropertyPage in MFC. update solved?? Pin
David Crow18-Sep-13 2:50
David Crow18-Sep-13 2:50 
AnswerRe: Unable to set focus in CPropertyPage in MFC. update solved?? Pin
Vaclav_18-Sep-13 7:50
Vaclav_18-Sep-13 7:50 
QuestionOutlook Addins Pin
john563216-Sep-13 22:55
john563216-Sep-13 22:55 
AnswerRe: Outlook Addins Pin
Richard MacCutchan17-Sep-13 0:31
mveRichard MacCutchan17-Sep-13 0:31 
Questionhow to lock function? Pin
JoneLe8616-Sep-13 18:09
JoneLe8616-Sep-13 18:09 
AnswerRe: how to lock function? Pin
Richard MacCutchan16-Sep-13 20:41
mveRichard MacCutchan16-Sep-13 20:41 
AnswerRe: how to lock function? Pin
CPallini16-Sep-13 21:18
mveCPallini16-Sep-13 21:18 
AnswerRe: how to lock function? Pin
Freak3016-Sep-13 22:06
Freak3016-Sep-13 22:06 
If you want something inside the function protected from parallel/recursive calls, you can do that by placing a criitical section and a class member variable inside it. If don't want the function to be called at all, you could make it private and add a public function as the only one that calls it. It could look something like that:
C++
void somePublicFunc()
{
    EnterCriticalSection(); // keep other treads out
    try
    {
        if (!alreadyRunning) // static private member variable to prevent recursive calls
        {
            alreadyRunning = true;
            privateFunction();
            alreadyRunning = false;
        }
    }
    catch (...)
    {
        alreadyRunning = false; // important to do that before leaving the critical section
        LeaveCriticalSection(); // prevent a dead lock
        throw; // let the caller decide what to do with the initial exception
    }
    LeaveCriticalSection();
}

So privateFunction() will only be called once at a time no matter from which thread (provided you don't add another member function that calls it or introduce any friend classes).
The good thing about pessimism is, that you are always either right or pleasently surprised.

GeneralRe: how to lock function? Pin
pasztorpisti17-Sep-13 0:27
pasztorpisti17-Sep-13 0:27 
QuestionWhat does it mean when...... Pin
Richard Andrew x6416-Sep-13 10:42
professionalRichard Andrew x6416-Sep-13 10:42 
AnswerRe: What does it mean when...... Pin
Graham Breach16-Sep-13 11:26
Graham Breach16-Sep-13 11:26 
GeneralRe: What does it mean when...... Pin
Richard Andrew x6416-Sep-13 11:51
professionalRichard Andrew x6416-Sep-13 11:51 
QuestionFeedback appreciated Pin
Marco Bertschi16-Sep-13 0:15
protectorMarco Bertschi16-Sep-13 0:15 
AnswerRe: Feedback appreciated Pin
pasztorpisti16-Sep-13 0:54
pasztorpisti16-Sep-13 0:54 
AnswerRe: Feedback appreciated Pin
Richard MacCutchan16-Sep-13 0:54
mveRichard MacCutchan16-Sep-13 0:54 
AnswerRe: Feedback appreciated - OT Pin
Richard MacCutchan16-Sep-13 20:39
mveRichard MacCutchan16-Sep-13 20:39 
GeneralRe: Feedback appreciated - OT Pin
SoMad16-Sep-13 21:23
professionalSoMad16-Sep-13 21:23 
GeneralRe: Feedback appreciated - OT Pin
Marco Bertschi16-Sep-13 21:59
protectorMarco Bertschi16-Sep-13 21:59 
AnswerRe: Feedback appreciated Pin
Stefan_Lang17-Sep-13 1:42
Stefan_Lang17-Sep-13 1:42 
AnswerRe: Feedback appreciated Pin
Vaclav_17-Sep-13 10:21
Vaclav_17-Sep-13 10:21 
Questiondebug begining: Unhandled exception at 0x77cf15de in blast_vib_proc.exe: 0xC00000FD: Stack overflow. Pin
mrby12314-Sep-13 16:18
mrby12314-Sep-13 16:18 
SuggestionRe: debug begining: Unhandled exception at 0x77cf15de in blast_vib_proc.exe: 0xC00000FD: Stack overflow. Pin
Richard MacCutchan14-Sep-13 21:42
mveRichard MacCutchan14-Sep-13 21:42 
AnswerRe: debug begining: Unhandled exception at 0x77cf15de in blast_vib_proc.exe: 0xC00000FD: Stack overflow. Pin
Marco Bertschi15-Sep-13 10:39
protectorMarco Bertschi15-Sep-13 10:39 
Questionas soon as start program got error message - stack overflow Pin
mrby12313-Sep-13 19:35
mrby12313-Sep-13 19:35 
AnswerRe: as soon as start program got error message - stack overflow Pin
Richard MacCutchan13-Sep-13 22:26
mveRichard MacCutchan13-Sep-13 22:26 

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.