Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27196

VS 2010 Add Delay To When A Process Has Exit

$
0
0
Me again, hmm scrap "displaying a %".........

how can i update label5 and set a 3/4 sec pause if the process has exited, i tried:
Code:

                    If (myProcess.HasExited) Then
                        Timer1.Enabled = False
                        Label5.Text = "100%"
                    End If

- didn't work.......

1. Where would i add such code??
2. Is timer1 even ok??

here's my code:
Code:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        PictureBox2.ImageLocation = ".\images\Logo.png"
        If Not (System.IO.File.Exists(file_name)) Then
            MessageBox.Show("The programs opted for this OS can't be installed as the InstallCFG.ini has not been included...")
        End If

        line = stream_reader.ReadLine() 'Read InstallCFG.ini File

        Do While Not (line Is Nothing)
            ReadResult = line.Split(":") 'Split line at :

            If (ReadResult(0).ToLower() = "prog name") Then
                PictureBox1.ImageLocation = ".\images\System-Idle.png"
                If (ReadResult(1) = "Preparing Files") Then
                    PictureBox1.ImageLocation = ".\images\System-Preparing.png"
                Else
                    PictureBox1.ImageLocation = ".\images\System-Working.png"
                    Label3.Text = "Installing " + ReadResult(1)
                End If
            End If

            If (ReadResult(0).ToLower() = "installer file") Then
                Label3.Refresh()
                If (System.IO.File.Exists(ReadResult(1))) Then
                    'Label4.Text = "path: " & ReadResult(1)
                    Dim info As New System.Diagnostics.ProcessStartInfo
                    info.FileName = ReadResult(1) 'Open the application

                    Dim myProcess As New System.Diagnostics.Process
                    myProcess.StartInfo = info
                    myProcess.Start() 'Start the process
                    myProcess.WaitForExit() 'Wait until the process started is finished
                    myProcess.Close() 'Release the resources
                Else
                    MessageBox.Show("Something is wrong! File = " & ReadResult(1))
                End If
            End If
            line = stream_reader.ReadLine() 'Move on to the next line.
        Loop
        stream_reader.Close()
    End Sub


Viewing all articles
Browse latest Browse all 27196

Trending Articles