Start Process; wait until finished

Nate Bross

Contributor
Joined
Apr 6, 2005
Messages
601
Location
Chicago, IL
I know I have seen several threads about this. Working on a program, I needed to achieve the same functionality so I hacked this little example together; I'm sure there's a better way but this works pretty well.

Visual Basic:
                System.Diagnostics.Process.Start("C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2005\\Projects\\eBay Search\\EbaySearch.exe")

                'while external program is running
                While bSkipDBCheck = True
                    'set program running to false (so we don't loop endlessly)
                    bSkipDBCheck = False
                    'for each process running
                    For Each x As System.Diagnostics.Process In System.Diagnostics.Process.GetProcesses()
                        'check current process
                        If x.ProcessName.ToString() = "EbaySearch" Then
                            'its the one we want to let finish so make sure we stay in the do loop
                            bSkipDBCheck = True
                        End If
                    Next
                    'don't freeze the computer
                    Application.DoEvents()
                End While
'Code to run after the external program has completed

I'll post a C# conversion sometime later on.
 
Back
Top