How to implement a C++ callback in C# -
i'm having real troubles trying use c++ callback in c# , appreciated.
the first thing code create event:
uevent = createevent(null, true, false, "eventname");
after that, i've got c++ function implements callback in c++:
int registercallback(tcallbacktype callbacktype, void *plltprofilecallback, void *puserdata)
the callbacktype used specify stdcall. then, plltprofilecallback name of function call, , finally, user data.
with function, i'm able make callback function typing following:
registercallback(std_call, (void*)functionname, 0)
where other function is:
void __stdcall functionname(const unsigned char* pucdata, unsigned int uisize, void* puserdata)
and then, i've got code wait event:
waitforsingleobject(uevent, 1000)
my problem comes when try in c#. first thing import registercallback function dll:
[dllimport(driver_dll_name, entrypoint = "s_registercallback",callingconvention = callingconvention.stdcall)] internal static extern int registercallback(uint pllt, tcallbacktype callbacktype, intptr plltprofilecallback, intptr puserdata);
but then, don't know how proceed. please me?
delegates in c# equivalent c++ callback.
please refer msdn introduction & syntax , usage same
Comments
Post a Comment