Estimados.

Tengo que acceder a unas funciones en una liberia c++ desde c#. Estoy teniendo 
problemas para subscribirme a un callback.

La firma en C++ son:

 

int WINAPI LSCAN_Capture_RegisterCallbackResultImage(

 const int handle, ///< [in] Device handle obtained by LSCAN_Main_Initialize()

 LSCAN_CallbackResultImage callback, ///< [in] Pointer to the notification 
function 

 void *context ///< [in] Pointer to user context; this value is used as 
parameter for callback

 );

 

 

///// Result image availability notification function.

///// To register for the notification call 
LSCAN_Capture_RegisterCallbackResultImage().

///// @param deviceHandle device handle to identify device the callback is 
called for

///// @param pContext caller defined context (e.g. handler object instance 
pointer)

///// @param imageStatus result image status value (value >= LSCAN_STATUS_OK 
indicates success)

///// @param image result image (valid until callback function is exited)

///// @param imageType if auto capture license available and imageStatus >= 
LSCAN_STATUS_OK: 

///// detected result image type (e.g. LSCAN_ROLL_SINGLE_FINGER) \n

///// else if imageStatus >= LSCAN_STATUS_OK: image type as selected by 

///// LSCAN_Capture_SetMode() \n

///// else: @ref LSCAN_TYPE_NONE

///// @param detectedObjects if imageStatus >= LSCAN_STATUS_OK and auto capture 
license available: 

///// number of detected objects/fingers in result image \n

///// else: -1 

//typedef void (CALLBACK *LSCAN_CallbackResultImage)(

// const int deviceHandle,

// void *pContext,

// const int imageStatus,

// const ImageData image,

// const LScanImageType imageType,

// const int detectedObjects

// );

 

 

Lo tengo implementado de esta manera en C#:

 

public delegate int LSCAN_CallbackResultImage(

int deviceHandle,IntPtr pContext, int imageStatus, ImageData image, 
LScanImageType imageType, int detectedObjects);

 

[System.Runtime.InteropServices.DllImport("LScanEssentials.DLL")]

public static extern int LSCAN_Capture_RegisterCallbackResultImage(int handle,

LSCAN_CallbackResultImage CallbackResultImage, IntPtr Context);

 

Y desde el form donde uso las funciones asi:

GuardianFunctions.LSCAN_Capture_RegisterCallbackResultImage(ScnHandler,

new GuardianFunctions.LSCAN_CallbackResultImage(callbackresult), 
pictureBox1.Handle);

 

El tema es que no se estan comunicando, y normalmente obtengo el error 
CallbackOnCollectedDelegate was detected

Alguna idea?

Gracias



 

_________________________________________________________________
Disfrutá todos los especiales que MSN tiene para vos
http://especiales.latam.msn.com/cl

Responder a