NegotiateStream.EndWrite(IAsyncResult) 方法
定义
结束通过调用 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 而启动的异步写操作。Ends an asynchronous write operation that was started with a call to 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)
参数
- asyncResult
- IAsyncResult
调用 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 后返回的 IAsyncResult 实例An IAsyncResult instance returned by a call to BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)
例外
asyncResult 为 null。asyncResult is null.
asyncResult 并不是通过调用 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 而创建的。The asyncResult was not created by a call to BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object).
没有处于挂起状态的写操作要完成。There is no pending write operation to complete.
或-or-
未进行身份验证。Authentication has not occurred.
写操作失败。The write operation failed.
示例
下面的示例演示了一个方法,该方法用于完成异步写入操作。The following example demonstrates a method that is called to complete the asynchronous write operation. 有关演示如何启动操作的示例,请参见 BeginWrite 。For an example that demonstrates starting the operation, see 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
注解
如果操作尚未完成,则此方法将一直阻止到该操作。If the operation has not completed, this method blocks until it does.
在成功完成身份验证之前,你无法调用此方法。You cannot call this method until you have successfully authenticated. 若要进行身份验证,请调用、、、、 AuthenticateAsClient AuthenticateAsClientAsync BeginAuthenticateAsClient AuthenticateAsServer AuthenticateAsServerAsync 或 BeginAuthenticateAsServer 方法之一。To authenticate, call one of the AuthenticateAsClient, AuthenticateAsClientAsync, BeginAuthenticateAsClient, AuthenticateAsServer, AuthenticateAsServerAsync, or BeginAuthenticateAsServer methods.
若要同步执行此操作,请使用 Write 方法。To perform this operation synchronously, use the Write method.