Skip to content

Help with callbacks in C#

cajuginja

Asked Mar 8, 2006, 1:27 AM EST1 answer
Share
LinkedInX

Hello
I have the following code written in c++ 6.0.
I need to write it in C# 2.0 , but i don't know
how to define those callbacks in C#.
Is it possible to use that API in C#?
Can any one help me?

Thank You
Caju Ginja

 


TEST.h

C#
typedef DWORD (CALLBACK* PACCOMSVRCALLBACK_CONNECT)(LPVOID, AC_TERMINAL_CONNECTINFO*, LPDWORD);
typedef DWORD (CALLBACK* PACCOMSVRCALLBACK_DISCONNECT)(LPVOID, DWORD);
typedef struct {
 PACCOMSVRCALLBACK_CONNECT    pCallbackConnect;
 PACCOMSVRCALLBACK_DISCONNECT    pCallbackDisconnect;
} AC_CALLBACK_FUNCTION_1;
void WINAPI ACCOM_SetCallbackFunctions(LPVOID pParam, DWORD nCallbackType, LPVOID pCallbacks);

///////////////////////////////////////////////////////////////
TEST.CPP
 AC_CALLBACK_FUNCTION_1 callbacks;
 memset(&callbacks, 0, sizeof(AC_CALLBACK_FUNCTION_1));
 callbacks.pCallbackConnect = NULL;
 callbacks.pCallbackDisconnect = Callback_Disconnected;
 ACCOM_SetCallbackFunctions( this, 1, &callbacks);
////////////////////////////////////////////////////////////////////

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    you can accomplish callbacks in C# with Asynchronous Method Invocation.

    This uses delegates, along with the delegate you can pass a callback method when the task completes.

    I don't know the code off by heart, but search groups.google.com for C# Asynchronous callback and you'll see some code to accomplish this.
    0