S
Shawn.Janson
Guest
Hello all; I am attempting to create a program that will run iPERF using a nice graphical UI (along with some other tests), and sometimes I have to run iPERF as long as 30 minutes. If you are not aware of iPERF, it is a command line application which can be run in Win 10. I have figured out how to easily save it to a file, then read the file and display it; however I would prefer to have the output occur as it tests, so I can see if there is anything not working as intended along the way (20 min would be a long time to wait to only find out the results were useless or something happened 5 min in). Below is my code to perform a few functions within the application (checking user input, ETC), then initiate iperf through the shell command and have iperf save the results to a text file (iperf locks the file and will cancel on shared access), then after an approximated amount of time wait until the iperf3.exe process closes (to avoid interrupting the file), then read the file and display the file.
Unfortunately, I can't seem to figure out how to get the results to display live. iPERF3 does not output to the command window when it is running, the file is locked, and yeah, I am out of ideas. Any help is greatly appreciated!!
note: ignore some of the surrounding items such as the function verifyParameters or setting testStr to "paused" - those all work as intended on items not directly impacting this part.
code below (i know it could be written better, but I am old and self taught):
Private Sub btnIperf_Click(sender As Object, e As EventArgs) Handles btnIperf.Click
txtLog.AppendText("Short Throughput Initiated" + vbCrLf)
verifyParameters()
testCondition("start")
testStr = "iPerf"
lblCurTest.Text = testStr
count = 15
fileName = outputPath + "\throughput.txt"
If filesInt = 0 Then
If System.IO.File.Exists(fileName) = True Then
System.IO.File.Delete(fileName)
End If
End If
lblOutput.Text = "iPerf is in Progress. Please be patient...."
Shell("CMD.exe /C .\iperf3\iperf3 -c " + PIIP + " --logfile " + fileName, AppWinStyle.MinimizedNoFocus)
Do While (count > 0 And cancelAction = 0)
For i As Integer = 0 To wait * 50
System.Threading.Thread.Sleep(10)
Application.DoEvents()
Next
count = count - 1
pbTest.Value = Math.Floor(100 - (count / 15 * 100))
Loop
If cancelAction = 0 Then
CheckBGProcess()
Do While bgProcess.Count > 0
For i As Integer = 0 To 100
System.Threading.Thread.Sleep(10)
Application.DoEvents()
Next
CheckBGProcess()
Loop
Dim lineReader As String = ""
Dim fileReader As New System.IO.StreamReader(fileName)
Do While fileReader.Peek() <> -1
lineReader = lineReader & fileReader.ReadLine() & vbNewLine
Loop
lblOutput.AppendText(lineReader)
fileReader.Close()
End If
My.Computer.FileSystem.DeleteFile(fileName)
testStr = "Paused"
lblCurTest.Text = testStr
testCondition("end")
pbTest.Value = 0
txtLog.AppendText("Short Throughput Completed" + vbCrLf)
End Sub
really appreciate any help!
Continue reading...
Unfortunately, I can't seem to figure out how to get the results to display live. iPERF3 does not output to the command window when it is running, the file is locked, and yeah, I am out of ideas. Any help is greatly appreciated!!
note: ignore some of the surrounding items such as the function verifyParameters or setting testStr to "paused" - those all work as intended on items not directly impacting this part.
code below (i know it could be written better, but I am old and self taught):
Private Sub btnIperf_Click(sender As Object, e As EventArgs) Handles btnIperf.Click
txtLog.AppendText("Short Throughput Initiated" + vbCrLf)
verifyParameters()
testCondition("start")
testStr = "iPerf"
lblCurTest.Text = testStr
count = 15
fileName = outputPath + "\throughput.txt"
If filesInt = 0 Then
If System.IO.File.Exists(fileName) = True Then
System.IO.File.Delete(fileName)
End If
End If
lblOutput.Text = "iPerf is in Progress. Please be patient...."
Shell("CMD.exe /C .\iperf3\iperf3 -c " + PIIP + " --logfile " + fileName, AppWinStyle.MinimizedNoFocus)
Do While (count > 0 And cancelAction = 0)
For i As Integer = 0 To wait * 50
System.Threading.Thread.Sleep(10)
Application.DoEvents()
Next
count = count - 1
pbTest.Value = Math.Floor(100 - (count / 15 * 100))
Loop
If cancelAction = 0 Then
CheckBGProcess()
Do While bgProcess.Count > 0
For i As Integer = 0 To 100
System.Threading.Thread.Sleep(10)
Application.DoEvents()
Next
CheckBGProcess()
Loop
Dim lineReader As String = ""
Dim fileReader As New System.IO.StreamReader(fileName)
Do While fileReader.Peek() <> -1
lineReader = lineReader & fileReader.ReadLine() & vbNewLine
Loop
lblOutput.AppendText(lineReader)
fileReader.Close()
End If
My.Computer.FileSystem.DeleteFile(fileName)
testStr = "Paused"
lblCurTest.Text = testStr
testCondition("end")
pbTest.Value = 0
txtLog.AppendText("Short Throughput Completed" + vbCrLf)
End Sub
really appreciate any help!
Continue reading...