1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Private Sub Btn_hydro_Click(sender As Object, e As EventArgs) Handles btn_hydrolysys.Click
'Paramètres pour le processus
proc.StartInfo.WorkingDirectory = "C:\Users\Guigs\Test"
proc.StartInfo.FileName = "C:\Users\Guigs\Test1.exe"
proc.StartInfo.CreateNoWindow = True
Try
proc.Start()
While proc.HasExited = False
startBgw()
End While
proc.WaitForExit()
Catch ex As Exception 'si l'executable n'est pas lu
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 |
Partager