NegotiateStream.EndWrite(IAsyncResult) 方法

定义

结束通过调用 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 而启动的异步写操作。

public:
 override void EndWrite(IAsyncResult ^ asyncResult);
public override void EndWrite (IAsyncResult asyncResult);
override this.EndWrite : IAsyncResult -> unit
Public Overrides Sub EndWrite (asyncResult As IAsyncResult)

参数

例外

asyncResultnull

asyncResult 并不是通过调用 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 而创建的。

没有处于挂起状态的写操作要完成。

未进行身份验证。

写操作失败。

示例

以下示例演示了调用以完成异步写入操作的方法。 有关演示如何启动操作的示例,请参阅 BeginWrite

// The following method is called when the write operation completes.
static void EndWriteCallback( IAsyncResult^ ar )
{
   Console::WriteLine( L"Client ending write operation..." );
   NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(ar->AsyncState);
   
   // End the asynchronous operation.
   authStream->EndWrite( ar );
}

' The following method is called when the write operation completes.
Public Shared Sub EndWriteCallback(ar As IAsyncResult)

    Console.WriteLine("Client ending write operation...")
    Dim authStream = CType(ar.AsyncState, NegotiateStream)

    ' End the asynchronous operation.
    authStream.EndWrite(ar)

End Sub

注解

如果操作尚未完成,此方法将一直阻止,直到它完成。

在成功进行身份验证之前,无法调用此方法。 若要进行身份验证,请调用 、、AuthenticateAsClientAsyncAuthenticateAsServerAsyncBeginAuthenticateAsClientAuthenticateAsServer、 或 BeginAuthenticateAsServer 方法之一。AuthenticateAsClient

若要同步执行此操作,请使用 Write 方法。

适用于