0

I have a windows forms application (ItemInquiry.exe). I want to execute another windows forms application (ItemDownload.exe) and wait for that form to close.

My current code (In the calling application) looks like this:

private void menuFileItemDown_Click(object sender, EventArgs e)
{
    System.Diagnostics.Process itemDownProcess = 
      new System.Diagnostics.Process();

    itemDownProcess.StartInfo.FileName = "c:\bin\ItemDown.application";
    //Click-Once application

    itemDownProcess.Start();
    itemDownProcess.WaitForExit();
    loadItems();
}

loadItems executes immediately. I think that what is happening is that the .application file actually returns once it has loaded the (possibly updated) application.

Is there a way for the called application to notify the calling application that it has been closed short of using a semaphore?

Thanks

Mark Ainsworth
  • 811
  • 8
  • 24
  • possible duplicate of [How to wait on a process and all its child processes to exit?](http://stackoverflow.com/questions/8207994/how-to-wait-on-a-process-and-all-its-child-processes-to-exit) – GSerg Sep 13 '15 at 15:39
  • 1
    There is no way to do this by using the manifest file (ItemDown.application). The reason is that the manifest will be handled by the dfsvc.exe process which will then launch your application. So you will not be able to get your process to wait. You will need to send a message from one form to another, or switch to launching the executable file. – Luis Ramirez Sep 13 '15 at 21:05
  • Have you clicked the link @LuisRamirez? – GSerg Sep 13 '15 at 23:09
  • 1
    @ GASerg we should modify the question. I think this is more related to click once deployment and execution. I read the link and it would be the answer if it were not for the click once issue. I created a project to check the behavior based on marks code. His code would work if Mark were using the itemdownloader.exe. – Luis Ramirez Sep 14 '15 at 02:05
  • @LuisRamirez He already understands that when he launches `ItemDown.application` that starts a helper process and that helper process then starts the actual executable. It is correct to keep this behaviour because `ItemDown.application` may install the executable to various places. The link shows how to wait for the process tree in this situation. The problem is not unique to click-once, waiting for a process tree is a more common, generic problem. – GSerg Sep 14 '15 at 16:24

0 Answers0