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 / CLR / June 2004

Tip: Looking for answers? Try searching our database.

Deadlock in C#, CreateProcess, MFC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Werner B. Strydom - 27 May 2004 22:32 GMT
Hi,

I'm having some trouble launching an MFC application from a .NET
application. In a Winforms application [written in C#], I use the Process
class to start an MFC application. The MFC application creates, automates
and destroys several COM objects (including Microsoft Word) in a background
thread. Often we will get that the C# application causes the MFC application
deadlock, while the C# application waits for the process to terminate. If at
that time, I kill the C# application, the MFC application continues.

It seems to be deadlocking in WaitForSingleObject. Using a C++ managed
class, I used CreateProcess inside a managed class to spawn the MFC
application; and that deadlocks too in when WaitForSingleObject is called.
Again killing the .NET application is the only way to get the MFC
application to continue.

The only way I managed to fix it, is to use C++ managed code to call the MFC
code directly; that is without spawning off any process. However, if the MFC
application misbehaves, it does sabotage the managed code.

Do you perhaps have an idea why waiting for a MFC process to quit in C# or
C++ could cause that MFC process to deadlock?  This was done in the .NET
framework 1.0, and MFC 7.0.

Thanks
Werner
Jared Parsons [MSFT] - 01 Jun 2004 18:39 GMT
Are you using LoadLibrary() or running code in DllMain() in the C++
application?  If so check out this blog by CBrumme.  It's rather lengthy but
it may be related to the problem you are having.

   http://blogs.msdn.com/cbrumme/archive/2004/02/21/77595.aspx

Signature

Jared Parson [MSFT]
jaredpar@online.microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

> Hi,
>
[quoted text clipped - 22 lines]
> Thanks
> Werner

Rate this thread:







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.