Bonsoir à tous,
j'espère que vous pourrez m'aider, Je suis devant un problème un peu spécifique.
Je cherche à récupérer chaque caractères d'une ligne émise par RemuxTool (lancer par un objet Process).
Cette ligne à une particularité : C'est une suite de caractéres : "_" ajouté un par un pour représenter la progression du processus.
problème : En VB.NET je sais lire des lignes entières mais pas caractère par caractère. Hors j'ai besoin de détecter l’émission de chaque caratére pour faire mon propre formulaire de progression avec progressBar et calcul du temps restant...etc.
Voici le code que j'utilise et qui fonctionne trés bien quand il s'agit de lire ligne par ligne. :
Les Evenements DataReceived :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub ShellExecute(ByVal ExeFile As String, CommandLine As String) Dim MonProcess As New Process AddHandler MonProcess.OutputDataReceived, AddressOf OutputDataReceived AddHandler MonProcess.ErrorDataReceived, AddressOf ErrorDataReceived AddHandler MonProcess.Exited, AddressOf ProcessExit 'MonProcess.SynchronizingObject = Me MonProcess.EnableRaisingEvents = True MonProcess.StartInfo.FileName = ExeFile MonProcess.StartInfo.Arguments = CommandLine 'MonProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized MonProcess.StartInfo.CreateNoWindow = True ' True MonProcess.StartInfo.UseShellExecute = False ' False MonProcess.StartInfo.RedirectStandardOutput = True MonProcess.StartInfo.RedirectStandardInput = True MonProcess.StartInfo.RedirectStandardError = True MonProcess.Start() MonProcess.BeginOutputReadLine() MonProcess.BeginErrorReadLine() MonProcess.WaitForExit() MonProcess.Close() End Sub
Merci beaucoup si vous avez une idée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Private Sub OutputDataReceived(sender As Object, e As System.Diagnostics.DataReceivedEventArgs) Try ProcessOutputData = e.Data.ToString Invoquer(e.Data.ToString) Debug.Print(e.Data.ToString) Catch ex As Exception End Try End Sub Private Sub ErrorDataReceived(sender As Object, e As System.Diagnostics.DataReceivedEventArgs) Try ProcessOutputData = e.Data.ToString Invoquer(e.Data.ToString) Debug.Print(e.Data.ToString) Catch ex As Exception End Try End Sub
Partager