本人对编程懂的不多,求各位大神帮忙:
我想通过vb.net获取iperf测试返回的数据,但是现在只能获取到dos的内容,执行ping的话,收到的数据是正常的,而iperf的数据收不到,而且还会弹出dos窗口。麻烦帮忙看一下是怎么回事?
我的代码:
Private Sub TS_Start_Click(sender As Object, e As EventArgs) Handles TS_Start.Click
Try
myProcess.Refresh()
newThread = New Thread(AddressOf ThreadExcuteDos)
newThread.Start()
B_Folder.Enabled = False
B_Start.Enabled = False
B_Ping.Enabled = False
TS_Ping.Enabled = True
TS_Start.Enabled = True
TS_Stop.Enabled = True
T_Folder.ReadOnly = True
T_IP.ReadOnly = True
T_TestTime.ReadOnly = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Sub ThreadExcuteDos() '
myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
myProcess.StartInfo.CreateNoWindow = True
AddHandler myProcess.OutputDataReceived, AddressOf DataReceivedHandler
myProcess.Start()
myProcess.BeginOutputReadLine()
myProcess.StandardInput.WriteLine(cmd)
myProcess.WaitForExit()
myProcess.Close()
End Sub
Private Sub UpdateResult(ByVal strText As String)
TextBox1.AppendText(strText + Environment.NewLine)
If IsNothing(strText) Then
myProcess.CancelOutputRead()
End If
End Sub
Private Sub DataReceivedHandler(sender As Object, outLine As DataReceivedEventArgs)
Me.Invoke(New updateShow(AddressOf UpdateResult), outLine.Data)
End Sub