Process does not exit when using Process.Start & WaitForExit

if i start another CF app using the following code in NetCF2.0 the app never exits, it just seems to hang?

Dim pAsNew Process

Dim infoAsNew ProcessStartInfo("Sync.exe", "1")

p.StartInfo = info

p.Start()

p.WaitForExit()

If i run the app manually or step through it then it exits as expected. It's almost like the WaitForExit is keeping it alive or something?

Any ideas?

[834 byte] By [DeanStewart] at [2007-12-24]
# 1

No,WaitForExit() just waits for application to exits, it does not keep it alive. Must be something in Sync.exe which never exits if launched by main application. May be Sync.exe waits for resource held by main application, it’s up to you to investigate.

IlyaTumanov at 2007-8-31 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2

Yeah I guess i'll have to do some more digging.

I wrote a sample program with one form with a button on, when the button was clicked it fired off Sync.exe and called WaitForExit() and everything worked ok! Confused!!

It could be something to do with the fact that the code that calls Sync.exe is on a separate thread maybe? I'll post back when i find the answer!

DeanStewart at 2007-8-31 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3

Ok...

I found the problem, we use an implementation of p2pMessageQueue found on the MSDN site here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/inter_process_comm_netcf.asp

This Queue is used for IPC to send basic messages from Sync.exe to the main calling app. These messages are basic strings, usually one character "c" for complete, "e" for error "u" for a software upgrade available etc.

I create the queue just before calling the Sync.exe app and something in it seems to keep the Sync.exe alive, when i close the main app Sync.exe closes aswell.

This implementation works fine on a CE.NET 4.2 device but not on the WM5 device i have here.

Any ideas on how i could modify the code for WM5, or should i consider using MSMQ or somthing similar?

DeanStewart at 2007-8-31 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4

Ok, Just in case anyone is reading this.. the story so far...

I changed the message queue code to use the OpenNetCF.WindowsCE.Messaging.P2PMessageQueue and I still have the same problem. The problem occurs when the calling app opens a named Queue, then starts the second app as a process and calls WaitForExit. The second app then opens the same named queue and sends messages which DO get recieved by the calling app. However, when the second app finishes, it never actually closes, causing WaitForExit to lock the calling app. If i stop the calling app then both apps close.

This only occurs if I use the same named queue in both apps. It's like they are linked together through the queue? This all worked ok in PPC2003 and CE4.2, but in WM5.0 it's causing me a real headache! Help!!

DeanStewart at 2007-8-31 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 5

If you have reliable repro which is not using any 3rd party components, please file a bug report here.

IlyaTumanov at 2007-8-31 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 6
I have the same problem when starting tablediff.exe (using the -c option) which is part of SQL 2005 installation.
AndrewKLee at 2007-8-31 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...