SslStream.EndWrite(IAsyncResult) Método

Definición

Finaliza una operación de escritura asincrónica iniciada con una llamada previa a BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object).Ends an asynchronous write operation started with a previous 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)

Parámetros

Excepciones

asyncResult es null.asyncResult is null.

El parámetro asyncResult no se creó mediante una llamada a BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object).asyncResult was not created by a call to BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object).

No queda ninguna operación de escritura sin finalizar.There is no pending write operation to complete.

O bien-or-

No se ha producido la autenticación.Authentication has not occurred.

No se pudo realizar la operación de escritura.The write operation failed.

Ejemplos

En el ejemplo de código siguiente se muestra cómo finalizar una operación de escritura asincrónica.The following code example demonstrates ending an asynchronous write operation.

void WriteCallback( IAsyncResult^ ar )
{
   ClientState^ state = dynamic_cast<ClientState^>(ar->AsyncState);
   SslStream^ stream = state->stream;
   try
   {
      Console::WriteLine( L"Writing data to the client." );
      stream->EndWrite( ar );
   }
   catch ( Exception^ writeException ) 
   {
      Console::WriteLine( L"Write error: {0}", writeException->Message );
      state->Close();
      return;
   }

   Console::WriteLine( L"Finished with client." );
   state->Close();
}


void WriteCallback(IAsyncResult ar)
{
    ClientState state = (ClientState) ar.AsyncState;
    SslStream stream = state.stream;
    try
    {
        Console.WriteLine("Writing data to the client.");
        stream.EndWrite(ar);
    }
    catch (Exception writeException)
    {
        Console.WriteLine("Write error: {0}",
            writeException.Message);
        state.Close();
        return;
    }
    Console.WriteLine("Finished with client.");
    state.Close();
}

Comentarios

Si la operación no se ha completado, este método se bloquea hasta que lo hace.If the operation has not completed, this method blocks until it does.

Una aplicación no puede llamar a este método hasta que se haya autenticado correctamente.An application cannot call this method until you have successfully authenticated. Para realizar la autenticación, llame a uno de los AuthenticateAsClient métodos, o BeginAuthenticateAsClient , AuthenticateAsServer BeginAuthenticateAsServer .To authenticate, call one of the AuthenticateAsClient, or BeginAuthenticateAsClient, AuthenticateAsServer, BeginAuthenticateAsServer methods.

Para realizar esta operación sincrónicamente, use el Write método.To perform this operation synchronously, use the Write method.

Se aplica a