在调用此回调函数时,写了委托但是没有调用成功
下面是委托代码
[UnmanagedFunctionPointerAttribute(CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public delegate void CCallbackImp(int nEventID, structure.CR_Event pEvent);
下面是调用dll注册回到函数代码
[DllImport(@"CRInterface.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "CR_RegisterEventCallback")]
public extern unsafe static int CR_RegisterEventCallback(CCallbackImp pCallback);
回调函数具体代码
public static void CallBackFunction(int nEventID, structure.CR_Event pEvent)
{
MessageBox.Show("进入回调函数"+nEventID.ToString());
if (nEventID == (int)structure.CR_EventID.CR_EVT_NEW_FRAME)
{
MessageBox.Show(nEventID.ToString());
}
}
接口原理是当执行以下代码是,dll会自动调用回调函数,然后执行会到函数中的代码
resultprop = ImportDll.CR_StartAcquisition(cDETR_IDX, cFRM_NUM,(IntPtr) nBufSize, 1);
但是最后不知道哪儿错误了,么有进入回调函数中