i have a program i run, and i read the output, it stays open if i don't close it with: Apache_Proc.CloseMainWindow()
but if i do it to soon, i cant read the output.
Private Sub ap_test()
With Args
.FileName = sApache_dir & "\bin\apache.exe"
.Arguments = "-t -n """ & sApache_service & """ "
.UseShellExecute = False
.RedirectStandardError = True
.RedirectStandardOutput = True
.WindowStyle = ProcessWindowStyle.Hidden
End With
Apache_Proc = Process.Start(Args)
System.Threading.Thread.Sleep(5000)
Try
Apache_Proc.CloseMainWindow()
Catch ex As Exception
'do nothing
End Try
Dim sData As String = Apache_Proc.StandardError.ReadLine
If sData = "Syntax OK" Then
txtStatus.Text = txtStatus.Text & vbCrLf & "[" & GetTime() & "] " & "Apache Test result: Syntax OK"
If Me.Visible = False Then
SysTray.ShowBalloon(NotifyIcon2.NotifyIcon2.EBalloonIcon.Info, "Apache Test result: Syntax OK", "ApacheMon", 5)
End If
Else
txtStatus.Text = txtStatus.Text & vbCrLf & "[" & Date.Now.Hour & ":" & Date.Now.Minute & ":" & Date.Now.Second & "] " & "Apache Test result: Error found, please check your config"
If Me.Visible = False Then
SysTray.ShowBalloon(NotifyIcon2.NotifyIcon2.EBalloonIcon.Info, "Apache Test result: Error found, please check your config", "ApacheMon", 5)
End If
End If
End Sub
this is what i have now, and yes on a slow computer 5 sec maybe to litle, but i see no other way(if you do, feel free to comment)