bonjour;
je voudrais creer un speedtest avec wpf et iperf(exigé...)
donc tout marche nickel sauf pour afficher le resultat sur un control,voici le code,
je clique sur un bouton dans le fenetre principal pour executer ceci
en suite voici le fonction Process_OutputDataReceived9
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 string path = "cd C:\\Iperf"; string com = "iperf3 -c serveur -p5206 -P2 t3 -TUL"; string strCmdText = "/C " + path + "&" + com; ProcessStartInfo startInfo = new ProcessStartInfo("cmd", strCmdText) { WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true }; string str = string.Empty; Process process = Process.Start(startInfo); process.OutputDataReceived += Process_OutputDataReceived9; process.BeginOutputReadLine(); process.WaitForExit();
j'obtient une exception comme suit
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 if (e.Data != null) if (e.Data.StartsWith("UL: [SUM]") && !(e.Data.EndsWith("receiver") || (e.Data.EndsWith("sender")))) { string[] strTab = e.Data.Split(' '); Lbl_DL2.Content = strTab[13].ToString(); }
Le thread appelant ne peut pas accéder à cet objet parce qu'un autre thread en est propriétaire.
je comprend bien mais je ne sait pas comment résoudre ce problème.
une aide svp?
Partager