N
Nikolay Petrov
I have a class which starts a process and redirects it's output and input.
My class have a method which starts the process and another which stops it.
How can I check if the process have been already started, so I don't try to
start it again, and how to check if the process is not running so i don't
try to stop again?
code:
Public Class ProcEx
Private p As Process
Public Sub StartProcess()
p = New Process
With p.StartInfo
.FileName = "cmd"
.Arguments = ""
.CreateNoWindow = True
.ErrorDialog = False
.RedirectStandardError = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Hidden
.WorkingDirectory = Application.StartupPath
End With
p.Start()
End Sub
Public Sub StopProcess()
Dim RetVal As String
If Not p.HasExited Then
p.Kill()
End If
p.Close()
'p.Dispose()
End Sub
End Class
My class have a method which starts the process and another which stops it.
How can I check if the process have been already started, so I don't try to
start it again, and how to check if the process is not running so i don't
try to stop again?
code:
Public Class ProcEx
Private p As Process
Public Sub StartProcess()
p = New Process
With p.StartInfo
.FileName = "cmd"
.Arguments = ""
.CreateNoWindow = True
.ErrorDialog = False
.RedirectStandardError = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Hidden
.WorkingDirectory = Application.StartupPath
End With
p.Start()
End Sub
Public Sub StopProcess()
Dim RetVal As String
If Not p.HasExited Then
p.Kill()
End If
p.Close()
'p.Dispose()
End Sub
End Class