语言

Process.StartAndForget 方法

定义

重载

名称 说明
StartAndForget(ProcessStartInfo)

启动过程 startInfo,释放所有关联的资源,并返回进程 ID。

StartAndForget(String, IEnumerable<String>)

使用指定的文件名和可选参数启动进程,释放所有关联的资源,并返回进程 ID。

StartAndForget(ProcessStartInfo)

Source:
Process.Scenarios.cs

启动过程 startInfo,释放所有关联的资源,并返回进程 ID。

public:
 static int StartAndForget(System::Diagnostics::ProcessStartInfo ^ startInfo);
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static int StartAndForget(System.Diagnostics.ProcessStartInfo startInfo);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member StartAndForget : System.Diagnostics.ProcessStartInfo -> int
Public Shared Function StartAndForget (startInfo As ProcessStartInfo) As Integer

参数

startInfo
ProcessStartInfo

ProcessStartInfo包含用于启动进程的信息。

返回

已启动进程的进程 ID。

属性

例外

startInfo 是 null。

一个或多个 RedirectStandardInput, RedirectStandardOutput或 RedirectStandardError 设置为 true。 在火灾和忘记方案中不支持流重定向,因为必须清空重定向流以避免死锁。

- 或者 -

将 UseShellExecute 设置为 true。 在火灾和忘记方案中不支持 Shell 执行,因为Windows它可能不会创建新进程,因此无法返回有效的进程 ID。

注解

如果未提供标准句柄(StandardInputHandle或StandardOutputHandleStandardErrorHandle),则默认情况下会将其重定向到 null 文件。

此方法专为调用方想要启动进程且不需要与进程进一步交互的方案而设计。 它启动进程,释放所有关联的资源,并返回进程 ID。 启动的进程将继续独立运行。

适用于

StartAndForget(String, IEnumerable<String>)

Source:
Process.Scenarios.cs

使用指定的文件名和可选参数启动进程,释放所有关联的资源,并返回进程 ID。

[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static int StartAndForget(string fileName, System.Collections.Generic.IEnumerable<string>? arguments = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member StartAndForget : string * seq<string> -> int
Public Shared Function StartAndForget (fileName As String, Optional arguments As IEnumerable(Of String) = Nothing) As Integer

参数

fileName
String

要启动的可执行文件的名称。

arguments
IEnumerable<String>

要传递给进程的命令行参数。 传递 null 或空序列以启动进程,而无需其他参数。

返回

已启动进程的进程 ID。

属性

例外

fileName 是 null。

fileName 为空。

注解

此方法专为调用方想要启动进程且不需要与进程进一步交互的方案而设计。 它启动进程,捕获其进程 ID,释放所有关联的资源,并返回进程 ID。 启动的进程将继续独立运行。

默认情况下,标准句柄将重定向到 null 文件。

适用于