StringReader.ReadBlockAsync メソッド
定義
オーバーロード
ReadBlockAsync(Memory<Char>, CancellationToken) |
非同期的に、入力文字列の現在位置から開始してすべての文字を読み取り、現在位置を入力文字列の末尾に進めます。Asynchronously reads all the characters from the input string starting at the current position and advances the current position to the end of the input string. |
ReadBlockAsync(Char[], Int32, Int32) |
指定した最大文字数を現在の文字列から非同期的に読み取り、バッファーの指定したインデックス位置にそのデータを書き込みます。Reads a specified maximum number of characters from the current string asynchronously and writes the data to a buffer, beginning at the specified index. |
ReadBlockAsync(Memory<Char>, CancellationToken)
非同期的に、入力文字列の現在位置から開始してすべての文字を読み取り、現在位置を入力文字列の末尾に進めます。Asynchronously reads all the characters from the input string starting at the current position and advances the current position to the end of the input string.
public override System.Threading.Tasks.ValueTask<int> ReadBlockAsync (Memory<char> buffer, System.Threading.CancellationToken cancellationToken = default);
override this.ReadBlockAsync : Memory<char> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
Public Overrides Function ReadBlockAsync (buffer As Memory(Of Char), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)
パラメーター
このメソッドから戻ったときは、現在のソースから読み取られた文字が格納されています。When this method returns, contains the characters read from the current source. 読み取られた合計文字数が 0 の場合、スパンは変更されません。If the total number of characters read is zero, the span remains unmodified.
- cancellationToken
- CancellationToken
キャンセル要求を監視するためのトークン。The token to monitor for cancellation requests. 既定値は None です。The default value is None.
戻り値
非同期読み取り操作を表すタスク。A task representing the asynchronous read operation. TResult
パラメーターの値には、バッファーに読み込まれる文字の合計数が含まれます。The value of the TResult
parameter contains the total number of characters read into the buffer.
注釈
ReadBlockAsync(Memory<Char>, CancellationToken) を ReadBlock(Span<Char>) 非同期で呼び出し、さらにを Read(Span<Char>) 直接呼び出します。ReadBlockAsync(Memory<Char>, CancellationToken) calls ReadBlock(Span<Char>) asynchronously, which in turn calls Read(Span<Char>) directly.
適用対象
ReadBlockAsync(Char[], Int32, Int32)
指定した最大文字数を現在の文字列から非同期的に読み取り、バッファーの指定したインデックス位置にそのデータを書き込みます。Reads a specified maximum number of characters from the current string asynchronously and writes the data to a buffer, beginning at the specified index.
public:
override System::Threading::Tasks::Task<int> ^ ReadBlockAsync(cli::array <char> ^ buffer, int index, int count);
public override System.Threading.Tasks.Task<int> ReadBlockAsync (char[] buffer, int index, int count);
[System.Runtime.InteropServices.ComVisible(false)]
public override System.Threading.Tasks.Task<int> ReadBlockAsync (char[] buffer, int index, int count);
override this.ReadBlockAsync : char[] * int * int -> System.Threading.Tasks.Task<int>
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.ReadBlockAsync : char[] * int * int -> System.Threading.Tasks.Task<int>
Public Overrides Function ReadBlockAsync (buffer As Char(), index As Integer, count As Integer) As Task(Of Integer)
パラメーター
- buffer
- Char[]
このメソッドが戻るとき、指定した文字配列の index
から (index
+ count
- 1) までの値が、現在のソースから読み取られた文字に置き換えられます。When this method returns, contains the specified character array with the values between index
and (index
+ count
- 1) replaced by the characters read from the current source.
- index
- Int32
書き込みを開始する buffer
内の位置。The position in buffer
at which to begin writing.
- count
- Int32
読み取り対象の最大文字数。The maximum number of characters to read. 指定された文字数をバッファーに書き込む前に文字列の末尾に到達した場合、メソッドは制御を返します。If the end of the string is reached before the specified number of characters is written into the buffer, the method returns.
戻り値
非同期の読み取り操作を表すタスク。A task that represents the asynchronous read operation. TResult
パラメーターの値には、バッファーに読み込まれるバイトの合計数が含まれます。The value of the TResult
parameter contains the total number of bytes read into the buffer. 現在使用できるバイト数が要求した数より小さい場合、結果の値は要求したバイト数より小さくなることがあります。また、文字列の末尾に到達した場合は 0 になることがあります。The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the string has been reached.
- 属性
例外
buffer
が null
です。buffer
is null
.
index
または count
が負の値です。index
or count
is negative.
index
と count
の合計が、バッファーの長さよりも大きいです。The sum of index
and count
is larger than the buffer length.
文字列リーダーは破棄されています。The string reader has been disposed.
リーダーは、前の読み取り操作によって現在使用されています。The reader is currently in use by a previous read operation.
注釈
このタスクは、パラメーターで指定された文字数が読み込まれるか、 count
文字列の末尾に到達するまでは完了しません。The task does not complete until either the number of characters specified by the count
parameter are read, or the end of the string has been reached.