views:

30

answers:

1
if (b->InvokeRequired) {
    FuncDelegat^ as = gcnew FuncDelegat(funct1);
    b->Invoke(as,nullptr);
    return;
}

Why that code may not the call function funct1

+1  A: 

funct1 is not called if InvokeRequired returns false. Correct way:

    if (b->InvokeRequired) 
    {
        FuncDelegat^ as = gcnew FuncDelegat(funct1);
        b->Invoke(as,nullptr);
    }
    else
    {
        b->funct1(nullptr);
    }
    return;
Alex Farber
I added it to the code, but still a function call during a flag does not occur.
Xaver
Please provide more information: what is b, delegate type, funct1 definition etc.
Alex Farber
b it is a Form class. i create new thread which must work with Form. For this i have a function funct1. The delegate FuncDelegat:delegate void FuncDelegat();
Xaver