Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​IO.​Pipes.​PipeStream
Assembly: System.IO.Pipes
Inheritance: object → MarshalByRefObject → Stream → PipeStream
Implemented Interfaces
- IAsyncDisposable Implemented by: Stream
- IDisposable Implemented by: Stream
Exposes a <see cref="T:System.IO.Stream" /> object around a pipe, which supports both anonymous and named pipes.
Properties
public
bool
CanRead
Gets a value indicating whether the current stream supports read operations.
public
bool
CanSeek
Gets a value indicating whether the current stream supports seek operations.
public
bool
CanWrite
Gets a value indicating whether the current stream supports write operations.
public
int
InBufferSize
Gets the size, in bytes, of the inbound buffer for a pipe.
public
bool
IsAsync
Gets a value indicating whether a <see cref="T:System.IO.Pipes.PipeStream" /> object was opened asynchronously or synchronously.
public
bool
IsConnected
Gets or sets a value indicating whether a <see cref="T:System.IO.Pipes.PipeStream" /> object is connected.
protected
bool
IsHandleExposed
Gets a value indicating whether a handle to a <see cref="T:System.IO.Pipes.PipeStream" /> object is exposed.
public
bool
IsMessageComplete
Gets a value indicating whether there is more data in the message returned from the most recent read operation.
public
long
Length
Gets the length of a stream, in bytes.
public
int
OutBufferSize
Gets the size, in bytes, of the outbound buffer for a pipe.
public
long
Position
Gets or sets the current position of the current stream.
public
PipeTransmissionMode
ReadMode
Gets or sets the reading mode for a <see cref="T:System.IO.Pipes.PipeStream" /> object.
SafePipeHandle
Gets the safe handle for the local end of the pipe that the current <see cref="T:System.IO.Pipes.PipeStream" /> object encapsulates.
public
PipeTransmissionMode
TransmissionMode
Gets the pipe transmission mode supported by the current pipe.
public
bool
CanTimeout
public
int
ReadTimeout
public
int
WriteTimeout
Methods
public
IAsyncResult
BeginRead​(byte[] buffer,
int offset,
int count,
AsyncCallback? callback,
object state)
Begins an asynchronous read operation.
Returns An <see cref="T:System.IAsyncResult" /> object that references the asynchronous read.
buffer
The buffer to read data into.
offset
The byte offset in <paramref name="buffer" /> at which to begin reading.
count
The maximum number of bytes to read.
callback
The method to call when the asynchronous read operation is completed.
state
A user-provided object that distinguishes this particular asynchronous read request from other requests.
public
IAsyncResult
BeginWrite​(byte[] buffer,
int offset,
int count,
AsyncCallback? callback,
object state)
Begins an asynchronous write operation.
Returns An <see cref="T:System.IAsyncResult" /> object that references the asynchronous write operation.
buffer
The buffer that contains the data to write to the current stream.
offset
The zero-based byte offset in <paramref name="buffer" /> at which to begin copying bytes to the current stream.
count
The maximum number of bytes to write.
callback
The method to call when the asynchronous write operation is completed.
state
A user-provided object that distinguishes this particular asynchronous write request from other requests.
protected
void
Dispose​(bool disposing)
Releases the unmanaged resources used by the <see cref="T:System.IO.Pipes.PipeStream" /> class and optionally releases the managed resources.
disposing
<see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.
public
int
EndRead​(IAsyncResult asyncResult)
Ends a pending asynchronous read request.
Returns The number of bytes that were read. A return value of 0 indicates the end of the stream (the pipe has been closed).
asyncResult
The reference to the pending asynchronous request.
public
void
EndWrite​(IAsyncResult asyncResult)
Ends a pending asynchronous write request.
asyncResult
The reference to the pending asynchronous request.
public
void
Flush​()
Clears the buffer for the current stream and causes any buffered data to be written to the underlying device.
FlushAsync​(Threading.​CancellationToken cancellationToken)
Asynchronously clears the buffer for the current stream and causes any buffered data to be written to the underlying device.
Returns A task that represent the asynchronous flush operation.
cancellationToken
The token to monitor for cancellation requests.
protected
void
InitializeHandle​(Microsoft.​Win32.​SafeHandles.​SafePipeHandle handle,
bool isExposed,
bool isAsync)
Initializes a <see cref="T:System.IO.Pipes.PipeStream" /> object from the specified <see cref="T:Microsoft.Win32.SafeHandles.SafePipeHandle" /> object.
handle
The <see cref="T:Microsoft.Win32.SafeHandles.SafePipeHandle" /> object of the pipe to initialize.
isExposed
<see langword="true" /> to expose the handle; otherwise, <see langword="false" /> .
isAsync
<see langword="true" /> to indicate that the handle was opened asynchronously; otherwise, <see langword="false" /> .
public
int
Read​(byte[] buffer,
int offset,
int count)
Reads a block of bytes from a stream and writes the data to a specified buffer starting at a specified position for a specified length.
Returns The total number of bytes that are read into <paramref name="buffer" /> . This might be less than the number of bytes requested if that number of bytes is not currently available, or 0 if the end of the stream is reached.
buffer
When this method returns, contains the specified byte array with the values between <paramref name="offset" /> and ( <paramref name="offset" /> + <paramref name="count" /> - 1) replaced by the bytes read from the current source.
offset
The byte offset in the <paramref name="buffer" /> array at which the bytes that are read will be placed.
count
The maximum number of bytes to read.
public
int
Read​(Span<​byte> buffer)
Reads a sequence of bytes from the current stream, writes them to a byte array, and advances the position within the stream by the number of bytes read.
Returns The total number of bytes read into the <paramref name="buffer" /> . This can be less than the number of bytes allocated in <paramref name="buffer" /> if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
buffer
A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.
public
Threading.​Tasks.​Task<​int>
ReadAsync​(byte[] buffer,
int offset,
int count,
Threading.​CancellationToken cancellationToken)
Asynchronously reads a sequence of bytes from the current stream to a byte array starting at a specified position for a specified number of bytes, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
Returns A task that represents the asynchronous read operation. The value of its <see cref="P:System.Threading.Tasks.Task`1.Result" /> property contains the total number of bytes read into the buffer. 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 stream has been reached.
buffer
The buffer to write the data into.
offset
The byte offset in <paramref name="buffer" /> at which to begin writing data from the stream.
count
The maximum number of bytes to read.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public
Threading.​Tasks.​ValueTask<​int>
ReadAsync​(Memory<​byte> buffer,
Threading.​CancellationToken cancellationToken = null)
Asynchronously reads a sequence of bytes from the current stream, writes them to a byte memory range, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
Returns A task that represents the asynchronous read operation. The value of its <see cref="P:System.Threading.Tasks.ValueTask`1.Result" /> property contains the total number of bytes read into the buffer. The result value can be less than the number of bytes allocated in the buffer if that many bytes are not currently available, or it can be 0 (zero) if the end of the stream has been reached.
buffer
The region of memory to write the data into.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public
int
ReadByte​()
Reads a byte from a pipe.
Returns The byte, cast to <see cref="T:System.Int32" /> , or -1 indicates the end of the stream (the pipe has been closed).
public
long
Seek​(long offset,
SeekOrigin origin)
Sets the current position of the current stream to the specified value.
Returns The new position in the stream.
offset
The point, relative to <paramref name="origin" /> , to begin seeking from.
origin
Specifies the beginning, the end, or the current position as a reference point for <paramref name="offset" /> , using a value of type <see cref="T:System.IO.SeekOrigin" /> .
public
void
SetLength​(long value)
Sets the length of the current stream to the specified value.
value
The new length of the stream.
public
void
WaitForPipeDrain​()
Waits for the other end of the pipe to read all sent bytes.
public
void
Write​(byte[] buffer,
int offset,
int count)
Writes a block of bytes to the current stream using data from a buffer.
buffer
The buffer that contains data to write to the pipe.
offset
The zero-based byte offset in <paramref name="buffer" /> at which to begin copying bytes to the current stream.
count
The maximum number of bytes to write to the current stream.
public
void
Write​(ReadOnlySpan<​byte> buffer)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
buffer
A region of memory. This method copies the contents of this region to the current stream.
WriteAsync​(byte[] buffer,
int offset,
int count,
Threading.​CancellationToken cancellationToken)
Asynchronously writes a specified number of bytes from a byte array starting at a specified position, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
Returns A task that represents the asynchronous write operation.
buffer
The buffer to write data from.
offset
The zero-based byte offset in <paramref name="buffer" /> from which to begin copying bytes to the stream.
count
The maximum number of bytes to write.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
WriteAsync​(ReadOnlyMemory<​byte> buffer,
Threading.​CancellationToken cancellationToken = null)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
Returns A task that represents the asynchronous write operation.
buffer
The region of memory to write data from.
cancellationToken
The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public
void
WriteByte​(byte value)
Writes a byte to the current stream.
value
The byte to write to the stream.
CopyToAsync​(Stream destination,
int bufferSize,
Threading.​CancellationToken cancellationToken)
Inherited from Stream
CopyToAsync​(Stream destination,
Threading.​CancellationToken cancellationToken)
Inherited from Stream
protected
Threading.​WaitHandle
CreateWaitHandle​()
Inherited from Stream
public
Threading.​Tasks.​Task<​int>
ReadAsync​(byte[] buffer,
int offset,
int count)
Inherited from Stream
public
int
ReadAtLeast​(Span<​byte> buffer,
int minimumBytes,
bool throwOnEndOfStream = true)
Inherited from Stream
public
Threading.​Tasks.​ValueTask<​int>
ReadAtLeastAsync​(Memory<​byte> buffer,
int minimumBytes,
bool throwOnEndOfStream = true,
Threading.​CancellationToken cancellationToken = null)
Inherited from Stream
ReadExactlyAsync​(byte[] buffer,
int offset,
int count,
Threading.​CancellationToken cancellationToken = null)
Inherited from Stream
ReadExactlyAsync​(Memory<​byte> buffer,
Threading.​CancellationToken cancellationToken = null)
Inherited from Stream
protected
MarshalByRefObject
MemberwiseClone​(bool cloneIdentity)
Inherited from MarshalByRefObject
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object