System.IO.Compression.GZipStream.BeginRead Method

Begins an asynchronous read operation. (Consider using the System.IO.Stream.ReadAsync(Byte[], int, int) method instead; see the Remarks section.)

Syntax

public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback cback, object state)

Parameters

buffer
Documentation for this section has not yet been entered.
cback
Documentation for this section has not yet been entered.
state
Documentation for this section has not yet been entered.
offset
The byte offset in array at which to begin reading data from the stream.
count
The maximum number of bytes to read.

Returns

An object that represents the asynchronous read operation, which could still be pending.

Remarks

Starting with the net_v45, you can perform asynchronous read operations by using the System.IO.Stream.ReadAsync(Byte[], int, int) method. The GZipStream.BeginRead(Byte[], int, int, AsyncCallback, object) method is still available in net_v45 to support legacy code; however, you can implement asynchronous I/O operations more easily by using the new async methods. For more information, see Asynchronous File I/O.

Pass the IAsyncResult return value to the GZipStream.EndRead(IAsyncResult) method of the stream to determine how many bytes were read and to release operating system resources used for reading. You can do this either by using the same code that called GZipStream.BeginRead(Byte[], int, int, AsyncCallback, object) or in a callback passed to GZipStream.BeginRead(Byte[], int, int, AsyncCallback, object).

The current position in the stream is updated when the asynchronous read or write is issued, not when the I/O operation completes.

Multiple simultaneous asynchronous requests render the request completion order uncertain.

Use the GZipStream.CanRead property to determine whether the current System.IO.Compression.GZipStream object supports reading.

If a stream is closed or you pass an invalid argument, exceptions are thrown immediately from GZipStream.BeginRead(Byte[], int, int, AsyncCallback, object). Errors that occur during an asynchronous read request, such as a disk failure during the I/O request, occur on the thread pool thread and throw exceptions when calling GZipStream.EndRead(IAsyncResult).

Requirements

Namespace: System.IO.Compression
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0