Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / March 2005

Tip: Looking for answers? Try searching our database.

Managed/Unmanaged : Threading code on which side?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
_R - 24 Mar 2005 12:36 GMT
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
Mattias Sj?gren - 24 Mar 2005 15:55 GMT
>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

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.