BufferedStream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 메서드

정의

비동기 읽기 작업을 시작합니다. 대신 ReadAsync(Byte[], Int32, Int32, CancellationToken)를 사용하세요.

public:
 override IAsyncResult ^ BeginRead(cli::array <System::Byte> ^ buffer, int offset, int count, AsyncCallback ^ callback, System::Object ^ state);
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback? callback, object? state);
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object? state);
override this.BeginRead : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
Public Overrides Function BeginRead (buffer As Byte(), offset As Integer, count As Integer, callback As AsyncCallback, state As Object) As IAsyncResult

매개 변수

buffer
Byte[]

데이터를 읽을 버퍼입니다.

offset
Int32

스트림에서 읽은 데이터를 쓰기 시작할 buffer의 바이트 오프셋입니다.

count
Int32

읽을 최대 바이트 수입니다.

callback
AsyncCallback

읽기가 완료되면 호출되는 선택적 비동기 콜백입니다.

state
Object

다른 요청에서 특정 비동기 읽기 요청을 구별하는 사용자 제공 개체입니다.

반환

IAsyncResult

보류 중인 비동기 읽기를 나타내는 개체입니다.

예외

buffer이(가) null인 경우

offset 또는 count가 음수입니다.

스트림 끝을 지나 비동기 읽기를 시도한 경우

버퍼 길이에서 offset를 빼면 count보다 작습니다.

현재 스트림이 읽기 작업을 지원하지 않는 경우

설명

.NET Framework 4 및 이전 버전에서는 비동기 파일 작업과 EndRead 같은 BeginRead 메서드를 사용하고 구현해야 합니다. 이러한 메서드는 레거시 코드를 지원하기 위해 .NET Framework 4.5에서 계속 사용할 수 있지만, 새로운 비동기 메서드(예: ReadAsync, WriteAsyncFlushAsync)는 비동기 파일 작업을 보다 쉽게 구현하는 데 도움이 됩니다.

EndWrite 에 대한 모든 호출에 대해 정확히 한 번 호출되어야 합니다 BeginRead. 다른 읽기를 시작하기 전에 읽기 프로세스를 종료하지 못하면 교착 상태와 같은 바람직하지 않은 동작이 발생할 수 있습니다.

참고

속성을 CanRead 사용하여 현재 인스턴스가 읽기를 지원하는지 여부를 확인합니다.

EndRead 읽은 바이트 수를 확인하려면 이 IAsyncResult 작업을 사용하여 호출해야 합니다.

적용 대상