Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.NET Progress status while run a EXE file

VB.NET Progress status while run a EXE file

Scheduled Pinned Locked Moved Visual Basic
csharplinuxquestion
21 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Andraw Tang

    Thanks, David. After I remove calling WaitForExit() and ReadToEnd(), the progressbar works now, but the Exited event function OnProcesited is not called, so the progressbar is always shown. How can I make OnProcesited() be called?

    Private Sub OnProcesited(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim p As System.Diagnostics.Process
    p = sender

        Dim rtnStr As String = String.Empty
        rtnStr = p.StandardOutput.ReadToEnd()
    
        If rtnStr.Contains(" FAST terminated normally.") = True Then
            rtnStr = rtnStr & vbCrLf & "Please click Postprocess -> View Output File in menu to view the file."
            updateViewMenu()
        End If
        progBarFrm.Close()
        progBarFrm.Dispose()
    
        Dim frm As New FormShowFASTResult
        frm.txtFASTResult.Text = rtnStr
        frm.Button1.Select()
        frm.ShowDialog()
    
    End Sub
    
    
    Private Sub Run\_Tool()
    
        Dim sAppPath As String = ".\\XXXXX.exe"
        Dim fileName As String = "XXXXX.txt"
        Dim p As New System.Diagnostics.Process()
    
    
    
        p.StartInfo.FileName = Application.StartupPath & "\\" & sAppPath
        p.StartInfo.Arguments = fileName
    
        'Do not use the system shell to start the program this is so we can hide the command dos window
        p.StartInfo.UseShellExecute = False
        p.StartInfo.WorkingDirectory = strOutputFilePath
        ' Show no dos window if false
        p.StartInfo.CreateNoWindow = True
        p.StartInfo.RedirectStandardOutput = True
        p.EnableRaisingEvents = True
        AddHandler p.Exited, AddressOf OnProcesited
    
    
        progBarFrm = New FormProgressBar
    
        Try
            p.Start()
    
            progBarFrm.Show()
            progBarFrm.Refresh()            
        Catch ex As Exception
            ShowValidationMessage("Unexception error is caught, please close and try again.", "Error")
            
            Return
        End Try    
    

    End Sub

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #21

    You can't force it. Your external process just hasn't stopped yet for some reason. Does your external process wait for the user to "Press any key to exit"?? I sure hope not!

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups