PipeReader.AdvanceTo Method

Definition

Moves forward the pipeline's read cursor to after the consumed data.

Overloads

AdvanceTo(SequencePosition)

Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed.

AdvanceTo(SequencePosition, SequencePosition)

Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed, read and examined.

Remarks

The memory for the consumed data will be released and no longer available. The Buffer previously returned from ReadAsync(CancellationToken) must not be accessed after this call. The examined data communicates to the pipeline when it should signal more data is available.

AdvanceTo(SequencePosition)

Source:
PipeReader.cs
Source:
PipeReader.cs
Source:
PipeReader.cs

Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed.

C#
public abstract void AdvanceTo(SequencePosition consumed);

Parameters

consumed
SequencePosition

Marks the extent of the data that has been successfully processed.

Remarks

The memory for the consumed data will be released and no longer available.

The Buffer previously returned from ReadAsync(CancellationToken) must not be accessed after this call.

This is equivalent to calling AdvanceTo(SequencePosition, SequencePosition) with identical examined and consumed positions. The examined data communicates to the pipeline when it should signal more data is available.

Because the consumed parameter doubles as the examined parameter, the consumed parameter should be greater than or equal to the examined position in the previous call to AdvanceTo. Otherwise, an InvalidOperationException is thrown.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

AdvanceTo(SequencePosition, SequencePosition)

Source:
PipeReader.cs
Source:
PipeReader.cs
Source:
PipeReader.cs

Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed, read and examined.

C#
public abstract void AdvanceTo(SequencePosition consumed, SequencePosition examined);

Parameters

consumed
SequencePosition

Marks the extent of the data that has been successfully processed.

examined
SequencePosition

Marks the extent of the data that has been read and examined.

Remarks

The memory for the consumed data will be released and no longer available.

The Buffer previously returned from ReadAsync(CancellationToken) must not be accessed after this call.

The examined data communicates to the pipeline when it should signal more data is available.

The examined parameter should be greater than or equal to the examined position in the previous call to AdvanceTo. Otherwise, an InvalidOperationException is thrown.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)