59 lines
2.1 KiB
VB.net
59 lines
2.1 KiB
VB.net
Module ExecProcessManager
|
|
|
|
Private m_ExecProcess As Process
|
|
|
|
Friend Function ExecProcess(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean
|
|
' lancio esecuzione programma
|
|
Dim bResult As Boolean = True
|
|
Dim Proc As New Process()
|
|
Proc.StartInfo.FileName = sFileName
|
|
Proc.StartInfo.RedirectStandardInput = False
|
|
Proc.StartInfo.RedirectStandardOutput = False
|
|
Proc.StartInfo.Arguments = 1.ToString() & " """ & sMainLuaPath & """ """ & sArguments & """"
|
|
Proc.StartInfo.UseShellExecute = False
|
|
Proc.StartInfo.CreateNoWindow = True
|
|
Dim ExecCounter = 0
|
|
If Proc.Start Then
|
|
While Not Proc.HasExited
|
|
If ExecCounter >= 300 Then
|
|
bResult = False
|
|
Proc.Kill()
|
|
Exit While
|
|
End If
|
|
Threading.Thread.Sleep(100)
|
|
ExecCounter += 1
|
|
End While
|
|
End If
|
|
Return bResult
|
|
End Function
|
|
|
|
Friend Function ExecProcessAsync(sFileName As String, sMainLuaPath As String, sArguments As String) As Boolean
|
|
If Not IsNothing(m_ExecProcess) Then
|
|
If Not m_ExecProcess.HasExited Then
|
|
m_ExecProcess.Kill()
|
|
End If
|
|
End If
|
|
' lancio esecuzione programma
|
|
Dim bResult As Boolean = True
|
|
m_ExecProcess = New Process()
|
|
m_ExecProcess.StartInfo.FileName = sFileName
|
|
m_ExecProcess.StartInfo.RedirectStandardInput = False
|
|
m_ExecProcess.StartInfo.RedirectStandardOutput = False
|
|
m_ExecProcess.StartInfo.Arguments = 1.ToString() & " """ & sMainLuaPath & """ """ & sArguments & """"
|
|
m_ExecProcess.StartInfo.UseShellExecute = False
|
|
m_ExecProcess.StartInfo.CreateNoWindow = True
|
|
Return m_ExecProcess.Start()
|
|
End Function
|
|
|
|
Friend Function CheckExecProcessAsync(ByRef bHasExited As Boolean, ByRef nExitCode As Integer) As Boolean
|
|
If IsNothing(m_ExecProcess) Then Return False
|
|
bHasExited = m_ExecProcess.HasExited
|
|
If bHasExited Then
|
|
nExitCode = m_ExecProcess.ExitCode
|
|
End If
|
|
Threading.Thread.Sleep(100)
|
|
Return True
|
|
End Function
|
|
|
|
End Module
|