Kathleen thank you for your patience,
Took a break to lure a large mouth bass but I can report I got the pointer working for the XMLPlus_GetItemDataByNaaccrId function. Somewhere in the code addition to support both the naaccrid and naaccrnum return values I over engineered the pointer assignment, nothing like a full re-write to flush out the bugs. The Edit50.dll worked like a charm when fed a proper pointer.
Steps to success:
Added a Pointer:
XMLPlus_Callbacks.Callback_ReadXmlData funcPtr1 =
new XMLPlus_Callbacks.Callback_ReadXmlData(ReadItemByNaaccrNum);
XMLPlus_Callbacks.Callback_ReadProgress funcPtr2 =
new XMLPlus_Callbacks.Callback_ReadProgress(ProgressFunc);
XMLPlus_Callbacks.Callback_ReadXmlData funcPtr3 =
new XMLPlus_Callbacks.Callback_ReadXmlData(ReadItemByNaaccrId);
Used a switch to set pointer:
if (cb_m1_byname.IsChecked == true)
{ readitem_callback = Marshal.GetFunctionPointerForDelegate(funcPtr3); }
else
{readitem_callback = Marshal.GetFunctionPointerForDelegate(funcPtr1); }
call the function with a switch:
if (cb_m1_byname.IsChecked == true)
{iRtn = XMLPlus_Interop.XMLPlus_GetItemDataByNaaccrId(xmlId, t_id); }
Else
{iRtn = XMLPlus_Interop.XMLPlus_GetItemDataByNaaccrNum(xmlId, t_num); }
I did end up using a global variable to pass the return value but will change that to have the functions call a generic function to build the output.
private static void ReadItemByNaaccrId(
System.IntPtr owner,
int patient_ordinal,
int tumor_ordinal,
[InAttribute()][MarshalAsAttribute(UnmanagedType.LPStr)] string NaaccrId,
int NaaccrNum,[InAttribute()][MarshalAsAttribute(UnmanagedType.LPStr)] string value)
{
globalVariable.sValue = value;
}
The test used a test file generated from the github test file generator with 5000 tumor records. The program loops through a patient with 7 field value calls to the get value function and loops through tumors with 127 calls to the function to build a delimited flat file of tumor with redundant patient info. It took ~11Min to process the file with Debugging on.