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
| p = New Process
p = Process.Start(info) 'Démarrer le processus
With p
'Lire tout le contenu de la sortie standard
AddHandler .OutputDataReceived, AddressOf Me.SortieProcessus
AddHandler .ErrorDataReceived, AddressOf Me.SortieErreur
.BeginErrorReadLine()
.BeginOutputReadLine()
End With
p.WaitForExit()
Private Sub SortieProcessus(ByVal sendingProcess As Object, ByVal outLine As DataReceivedEventArgs)
'Afficher une ligne de sortie de "Processus.cmd" si non vide
If String.IsNullOrEmpty(outLine.Data) = False Then
Me.Invoke(New SetTextHandler(AddressOf Me.SetText), outLine.Data)
End If
End Sub
Private Sub SortieErreur(ByVal sendingProcess As Object, ByVal ErreurMessage As DataReceivedEventArgs)
'Afficher une ligne de sortie de "Processus.cmd" si non vide
If String.IsNullOrEmpty(ErreurMessage.Data) = False Then
Me.Invoke(New SetTextHandler(AddressOf Me.SetText), ErreurMessage.Data)
End If
End Sub
Private Sub SetText(ByVal s As String)
If s Like "*TIME STEP NO*" Then
Me.Progression.AppendText(Environment.NewLine)
End If
Me.Progression.AppendText(s)
Me.Progression.AppendText(Environment.NewLine)
End Sub |
Partager