1
我需要执行commandpromt进程异步并获取执行的输出。我目前有这个代码执行命令提示进程asnyc并得到结果
Public Function ExecuteCommandSync(ByVal command As Object) As String
Dim result As String = Nothing
Try
Dim procStartInfo As New System.Diagnostics.ProcessStartInfo("cmd", "/c " & Convert.ToString(command))
procStartInfo.RedirectStandardOutput = True
procStartInfo.UseShellExecute = False
procStartInfo.CreateNoWindow = True
Dim proc As New System.Diagnostics.Process()
proc.StartInfo = procStartInfo
proc.Start()
result = proc.StandardOutput.ReadToEnd()
Console.WriteLine(result)
Catch objException As Exception
End Try
Return result
End Function
请帮助我将其转换为async,而不使用线程。这可能吗?
谢谢