Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15628

Progress bar while running .exe

$
0
0
I am developing an interface in which I call a calculation software which is an .exe

The execution time varying between 1 and 3 minutes depending on the input data, I try to display a progress bar to the user in that way they know that the app is working but the execution is quite long

I tried with a BackGroundWorker and a thread but i was not able to handle it.

Here is the code that i've now :


Code:

Private Sub Test_Click(sender As Object, e As EventArgs) Handles Test.Click
 
  'Parameters
        proc.StartInfo.WorkingDirectory = "C:\Users\Sam\Test"
        proc.StartInfo.FileName = "C:\Users\Sam\Test1.exe"
        proc.StartInfo.CreateNoWindow = True
 
Try
            proc.Start()
 
            While proc.HasExited = False
                startBgw()
            End While
 
 
 
 
            proc.WaitForExit()
 
 
        Catch ex As Exception
            MessageBox.Show("the processus is already running or the executable is lacking")
 
        End Try
 
End Sub
 
  Private Sub startBgw()
        bgw.WorkerReportsProgress = True
        bgw.RunWorkerAsync()
    End Sub
 
    Sub bgw_DoWork(sender As Object, e As DoWorkEventArgs) Handles bgw.DoWork
 
 
 
        For i As Integer = 0 To 10000
            If i Mod 1000 Then
                bgw.ReportProgress(i / 100)
            End If
        Next
 
    End Sub
 
    Sub bgw_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles bgw.ProgressChanged
 
 
        ProgressBar1.Value = e.ProgressPercentage
 
    End Sub

If anyone has an idea how I could handle this, thank you !

Viewing all articles
Browse latest Browse all 15628

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>