Wait for External Process to Complete with vb.net

Good Morning all! Yesterday was an intense day of coding as we are in the middle of rollout of our plans at work. These plans have what are called Elements, and those elements have element details, allocators, allocator details, allocator detail rules, rates, rate tables, rate table details, and rate table detail items.  i got tired of manually creating these when others were so close so I came up with code to duplicate the element and what was below to another plan. So I was happy.

Today’s topic is how to get your application to wait for an external process that you called with System.Diagnostics.Process to finish. Make it a great day!

Sub Main()
        Dim TgtDirectory As String = "MyDir\"
        Dim XYZFilter As String = "*.xyz"
        Dim FileList As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
        Dim Process As New System.Diagnostics.Process
        FileList = My.Computer.FileSystem.GetFiles(TgtDirectory, _
        FileIO.SearchOption.SearchTopLevelOnly, XYZFilter)
         For Each foundfile As String In FileList
            Using P As Process = Process.Start("dlg2dlx.bat", foundfile)
                P.WaitForExit()
            End Using
        Next
    End Sub


Join me on Facebook

Technorati Tags: ,,,,,,,,,,,,
,,,,,,,

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: