How to pass C# method as a callback to CLI/C++ function? -



How to pass C# method as a callback to CLI/C++ function? -

i have such method in c++/cli:

void foo(onengineclosecallback callback);

with such callback definition:

typedef void (*onengineclosecallback)( int, string ^ errormessage);

the c++/cli compiles. c# code looks this:

static void oncallback( int code, string errormessage) { system.diagnostics.debug.writeline(errormessage); }

and call:

foo(oncallback); // error

"foo not supported language" (error: cs0570).

so how can pass callback cli/c++?

if neither of going post reply i'll because don't answered questions without answers...

you must declare public delegate, not function pointer. basic how-to article here. hans passant

how to: define , utilize delegates (c++/cli)

c# callback c++-cli

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -