共用方式為


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)

參數

asyncResult
IAsyncResult

IAsyncResult 執行個體,由對 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 的呼叫所傳回。

例外狀況

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

備註

如果作業尚未完成,這個方法會封鎖直到它完成為止。

在成功驗證之前,您無法呼叫此方法。 若要進行驗證,請呼叫其中一個 AuthenticateAsClientAuthenticateAsClientAsyncBeginAuthenticateAsClientAuthenticateAsServerAuthenticateAsServerAsyncBeginAuthenticateAsServer 方法。

若要同步執行這項作業,請使用 Write 方法。

適用於