NamedPipeServerStream.WaitForConnectionAsync 方法

定义

异步等待客户端连接到该 NamedPipeServerStream 对象。Asynchronously waits for a client to connect to this NamedPipeServerStream object.

重载

WaitForConnectionAsync()

异步等待客户端连接到该 NamedPipeServerStream 对象。Asynchronously waits for a client to connect to this NamedPipeServerStream object.

WaitForConnectionAsync(CancellationToken)

异步等待客户端连接到此 NamedPipeServerStream 对象并监视取消请求。Asynchronously waits for a client to connect to this NamedPipeServerStream object and monitors cancellation requests.

WaitForConnectionAsync()

异步等待客户端连接到该 NamedPipeServerStream 对象。Asynchronously waits for a client to connect to this NamedPipeServerStream object.

public:
 System::Threading::Tasks::Task ^ WaitForConnectionAsync();
public System.Threading.Tasks.Task WaitForConnectionAsync ();
member this.WaitForConnectionAsync : unit -> System.Threading.Tasks.Task
Public Function WaitForConnectionAsync () As Task

返回

表示异步等待操作的任务。A task that represents the asynchronous wait operation.

注解

由于此方法是异步的,因此此方法会立即返回,但当客户端调用 ConnectConnectAsync时,将完成连接过程。Because it is asynchronous, this method returns immediately, but the connection process is completed when the client calls Connect or ConnectAsync.

WaitForConnectionAsync(CancellationToken)

异步等待客户端连接到此 NamedPipeServerStream 对象并监视取消请求。Asynchronously waits for a client to connect to this NamedPipeServerStream object and monitors cancellation requests.

public:
 System::Threading::Tasks::Task ^ WaitForConnectionAsync(System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task WaitForConnectionAsync (System.Threading.CancellationToken cancellationToken);
member this.WaitForConnectionAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function WaitForConnectionAsync (cancellationToken As CancellationToken) As Task

参数

cancellationToken
CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests.

返回

表示异步等待操作的任务。A task that represents the asynchronous wait operation.

注解

由于此方法是异步的,因此此方法会立即返回,但当客户端调用 ConnectConnectAsync时,将完成连接过程。Because it is asynchronous, this method returns immediately, but the connection process is completed when the client calls Connect or ConnectAsync.

使用取消标记的取消请求仅适用于使用管道选项值 PipeOptions.Asynchronous 创建的 NamedPipeServerStream 对象,或者如果在调用 WaitForConnectionAsync 方法之前发生了取消,则为。Cancellation requests using the cancellation token will only work if the NamedPipeServerStream object was created with a pipe option value of PipeOptions.Asynchronous or if the cancellation occurs before the WaitForConnectionAsync method is called.

适用于