CharSet=CharSet.Ansi SLOW duinrg batch processing (with interop functionality) of 15,000 records
Posted on 2004-04-14
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times, copy 3 fields of data of each row to a struct, and send the struct to an external method (using DLLImport).
The main problem is that the StructLayout attribute of this struct (which is also a parm to the method) is set at [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] - this makes the process take over 25 mins. It also lets the external function write correctly to other fields of the struct.
If we change it to CharSet.Unicode, the process takes less than than 1 min. but it doesn't seem to write anything to the struct. After I run the process, I notice that the struct fields have strange characters.
Is there some way I can keep using Unicode to keep the speed? I need to be able to read the data in the struct after the dll call.