ok, i've got a callback from some C++ code to some C# code to handle an array of data, and a data structure.
In C++ the callback is declared as:
int MyCallBack(const MyStruct* pMyStruct, unsigned short* pMyData, unsigned int nMyDataLength, void* pInfo);
I declare the delegate to handle this in C# as follows:
public delegate int MyCallBack(
ref MyStruct myStruct,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ushort[] myData,
uint myDataLength,
IntPtr userInfoStruct);
This all works fine so far.
However now i want to pass multiple arrays of data back to the C# in a single call to avoid some of the native->managed overhead
My declaration in C++ for the multiple callbacks is as follows:
int MyCallBack2(const MyStruct* pMyStruct, unsigned short** pMyDataArray, unsigned int* nMyDataLengthArray, unsigned int dataCount, void* pInfo);
I'm having some trouble figuring out the declaration for the delegate for this callback in the C#
This is what I've got so far:
public delegate int MyCallBack2(
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] MyStruct[] myStructArray,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] IntPtr[] myDataArray,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] int[] myDataLengthArray,
uint myDataCount,
IntPtr userInfoStruct);
Can anyone tell me how I get each of the ushort[] arrays from the IntPtrs in myDataArray above?
Thanks,
Pete