Managed/Unmanaged : Threading code on which side?

R

_R

I'm working on a project that entails calling into a legacy C DLL.
The original unmanaged test code (ancient C++) works OK, but
after generating managed C++ shells for calling the DLL via C#,
performance has taken a hit. I can't explain it--Smaller scale
tests run OK, but stressing the code causes unreliablility, presumably
in marshaling data. Hard to say what's going wrong.

I've been considering collecting all the unmanaged code calls into
one big unmanaged 'macro-function' that returns after it has its
result, which is basically the way the original code worked anyway.

Here's the Q: That 'macro-function' runs in a thread (to keep UI
responsive while it gets results). I've been wondering if there are
special concerns in calling unmanaged code from inside C# threads.
Maybe that has something to do with performance problems when
code is stressed.

Is it worthwhile to try to gen and run the thread from inside the
UNmanaged code? (Use the original unmanaged threading calls)
Would this have any advantage over generating the thread within
the C# code and calling the unmanaged macro-function from there?

R
 
M

Mattias Sjögren

I've been wondering if there are
special concerns in calling unmanaged code from inside C# threads.

It depends on the code you're calling. BUt in your case it doesn't
sound like it should cause a problem.

Is it worthwhile to try to gen and run the thread from inside the
UNmanaged code? (Use the original unmanaged threading calls)
Would this have any advantage over generating the thread within
the C# code and calling the unmanaged macro-function from there?

No, I don't see any advantage of doing it that way.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top