R
rollasoc
Hi,
I'm trying to get a list of COM ports on my machine using the API
GetDefaultCommConfig.
I've found an example in VB of how to do this but wanted to C# it up.
This works fine but is very slow in C#
In VB it searches for 16 COM Ports in less than a second.
In C# it searches for 10 COM Ports in about 3 seconds.
Why the difference in speed?
I did note in the Output window that the VB does the following once
'WindowsApplication2.exe': Loaded
'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\mi
crosoft.visualbasic.dll', No symbols loaded.
In C# I get the following in the Output window for each iteration
'MyApp.exe': Loaded 'C:\WINNT\system32\cfgmgr32.dll', No symbols loaded.
'MyApp.exe': Unloaded 'C:\WINNT\system32\cfgmgr32.dll'
plus several
'MyApp.exe': Loaded 'C:\WINNT\system32\serialui.dll', No symbols loaded.
'MyApp.exe': Unloaded 'C:\WINNT\system32\serialui.dll'
I'm assuming the extra time being taken is in the loading and unloading of
the libraries many many times.
How can I speed this up? (Seems a bit daft to have to create a whole VB
DLL just for one function call.
Any ideas?
Rollasoc
I'm trying to get a list of COM ports on my machine using the API
GetDefaultCommConfig.
I've found an example in VB of how to do this but wanted to C# it up.
This works fine but is very slow in C#
In VB it searches for 16 COM Ports in less than a second.
In C# it searches for 10 COM Ports in about 3 seconds.
Why the difference in speed?
I did note in the Output window that the VB does the following once
'WindowsApplication2.exe': Loaded
'c:\winnt\assembly\gac\microsoft.visualbasic\7.0.5000.0__b03f5f7f11d50a3a\mi
crosoft.visualbasic.dll', No symbols loaded.
In C# I get the following in the Output window for each iteration
'MyApp.exe': Loaded 'C:\WINNT\system32\cfgmgr32.dll', No symbols loaded.
'MyApp.exe': Unloaded 'C:\WINNT\system32\cfgmgr32.dll'
plus several
'MyApp.exe': Loaded 'C:\WINNT\system32\serialui.dll', No symbols loaded.
'MyApp.exe': Unloaded 'C:\WINNT\system32\serialui.dll'
I'm assuming the extra time being taken is in the loading and unloading of
the libraries many many times.
How can I speed this up? (Seems a bit daft to have to create a whole VB
DLL just for one function call.
Any ideas?
Rollasoc