Share via


PipeStream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) メソッド

定義

非同期の読み込み動作を開始します。

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);
[System.Security.SecurityCritical]
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback callback, object state);
override this.BeginRead : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
[<System.Security.SecurityCritical>]
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 オブジェクト。

属性

例外

buffernullです。

offset が 0 未満です。

または

count が 0 未満です。

countbuffer で使用可能なバイト数を超えています。

パイプは閉じています。

パイプが読み取り操作をサポートしていません。

パイプが接続解除されたか、パイプが接続を待機しているか、またはハンドルが設定されていません。

パイプが接続解除されているか、別の I/O エラーが発生しました。

注釈

返された IAsyncResult オブジェクトを メソッドに渡して EndRead 、読み取られたバイト数を確認し、読み取りに使用されるオペレーティング システム リソースを解放します。 EndRead の呼び出しごとに 1 回呼び出す BeginRead必要があります。 これは、 を呼び出 BeginRead したのと同じコードで、または に BeginRead渡されるコールバックで行うことができます。

プロパティを使用して、 CanRead 現在 PipeStream のオブジェクトが読み取り操作をサポートしているかどうかを判断します。

パイプが閉じているか、無効な引数が に BeginRead渡された場合、適切な例外が直ちに発生します。 非同期読み取り要求中に発生するエラーは、要求を実行しているスレッド プール スレッドで発生します。 例外は、コードが メソッドを呼び出すときに発生します EndRead

適用対象