Stream.EndWrite(IAsyncResult) Metodo
Definizione
Termina un'operazione di scrittura asincrona.Ends an asynchronous write operation. Si consiglia di usare WriteAsync(Byte[], Int32, Int32).(Consider using WriteAsync(Byte[], Int32, Int32) instead.)
public:
virtual void EndWrite(IAsyncResult ^ asyncResult);
public virtual void EndWrite (IAsyncResult asyncResult);
abstract member EndWrite : IAsyncResult -> unit
override this.EndWrite : IAsyncResult -> unit
Public Overridable Sub EndWrite (asyncResult As IAsyncResult)
Parametri
- asyncResult
- IAsyncResult
Riferimento alla richiesta di I/O asincrona in sospeso.A reference to the outstanding asynchronous I/O request.
Eccezioni
asyncResult
è null
.asyncResult
is null
.
Non è disponibile un handle dell'operazione di scrittura in sospeso.A handle to the pending write operation is not available.
-oppure--or-
L'operazione in sospeso non supporta la scrittura.The pending operation does not support writing.
asyncResult
non è stato generato da un metodo BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) nel flusso corrente.asyncResult
did not originate from a BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) method on the current stream.
Il flusso è chiuso o si è verificato un errore interno.The stream is closed or an internal error has occurred.
Commenti
In .NET Framework 4 e versioni precedenti è necessario usare metodi quali BeginWrite e EndWrite per implementare operazioni di I/O asincrone.In the .NET Framework 4 and earlier versions, you have to use methods such as BeginWrite and EndWrite to implement asynchronous I/O operations. Questi metodi sono ancora disponibili in .NET Framework 4.5.NET Framework 4.5 per supportare il codice legacy. Tuttavia, i nuovi metodi asincroni, ad esempio ReadAsync , WriteAsync , CopyToAsync e FlushAsync , consentono di implementare più facilmente le operazioni di I/O asincrone.These methods are still available in the .NET Framework 4.5.NET Framework 4.5 to support legacy code; however, the new async methods, such as ReadAsync, WriteAsync, CopyToAsync, and FlushAsync, help you implement asynchronous I/O operations more easily.
EndWrite
deve essere chiamato esattamente una volta per ogni IAsyncResult da BeginWrite .EndWrite
must be called exactly once on every IAsyncResult from BeginWrite.
Questo metodo mantiene il blocco fino al completamento dell'operazione di I/O.This method blocks until the I/O operation has completed. Gli errori che si verificano durante una richiesta di scrittura asincrona, ad esempio un errore del disco durante la richiesta di I/O, si verificano nel thread del pool di thread e diventano visibili durante una chiamata a EndWrite
.Errors that occur during an asynchronous write request, such as a disk failure during the I/O request, occur on the thread pool thread and become visible upon a call to EndWrite
. Le eccezioni generate dal thread del pool di thread non saranno visibili quando si chiama EndWrite
.Exceptions thrown by the thread pool thread will not be visible when calling EndWrite
.