25 internal readonly
bool _apm;
43 bool ITaskCompletionAction.InvokeMayRunArbitraryCode =>
true;
71 AsyncCallback callback = readWriteTask.
_callback;
72 readWriteTask._callback =
null;
73 callback(readWriteTask);
83 callback(completingTask);
132 protected override void Dispose(
bool disposing)
183 return Task.FromResult(0);
278 _stream.Position =
value;
291 _stream.ReadTimeout =
value;
303 _stream.WriteTimeout =
value;
322 base.Dispose(disposing:
true);
327 protected override void Dispose(
bool disposing)
340 base.Dispose(disposing);
534 [MemberNotNull(
"_asyncActiveSemaphore")]
629 long num2 =
length - position;
632 num = (int)
Math.
Min(num, num2);
650 protected virtual void Dispose(
bool disposing)
682 [Obsolete(
"CreateWaitHandle has been deprecated. Use the ManualResetEvent(false) constructor instead.")]
702 if (serializeAsynchronously)
708 semaphoreSlim.
Wait();
719 if (!readWriteTask2.
_apm)
734 return readWriteTask;
744 if (readWriteTask ==
null || !readWriteTask.
_isRead)
754 return readWriteTask.
GetAwaiter().GetResult();
788 int num = await readTask.
ConfigureAwait(continueOnCapturedContext:
false);
810 }, (
Stream stream,
ReadWriteParameters args, AsyncCallback callback,
object state) =>
stream.BeginRead(args.Buffer, args.Offset, args.Count, callback,
state), (
Stream stream,
IAsyncResult asyncResult) =>
stream.EndRead(
asyncResult));
827 if (serializeAsynchronously)
833 semaphoreSlim.
Wait();
845 if (!readWriteTask2.
_apm)
860 return readWriteTask;
885 task._endCalled =
true;
896 if (readWriteTask ==
null || readWriteTask.
_isRead)
962 }, (
Stream stream,
ReadWriteParameters args, AsyncCallback callback,
object state) =>
stream.BeginWrite(args.Buffer, args.Offset, args.Count, callback,
state), delegate(
Stream stream,
IAsyncResult asyncResult)
981 if ((uint)num > (uint)
buffer.Length)
996 byte[]
array =
new byte[1];
1038 [Obsolete(
"Do not call or override this method.")]
1066 if (bufferSize <= 0)
static ArrayPool< T > Shared
static void SuppressFinalize(object obj)
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override void Write(ReadOnlySpan< byte > buffer)
override Task FlushAsync(CancellationToken cancellationToken)
override long Seek(long offset, SeekOrigin origin)
override void Dispose(bool disposing)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override int Read(Span< byte > buffer)
override void CopyTo(Stream destination, int bufferSize)
override void EndWrite(IAsyncResult asyncResult)
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken)
override void WriteByte(byte value)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override void SetLength(long length)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
override void Write(byte[] buffer, int offset, int count)
override int EndRead(IAsyncResult asyncResult)
override int Read(byte[] buffer, int offset, int count)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
static void InvokeAsyncCallback(object completedTask)
ReadWriteTask(bool isRead, bool apm, Func< object, int > function, object state, Stream stream, byte[] buffer, int offset, int count, AsyncCallback callback)
ExecutionContext _context
static ContextCallback s_invokeAsyncCallback
override int EndRead(IAsyncResult asyncResult)
override long Seek(long offset, SeekOrigin origin)
override void EndWrite(IAsyncResult asyncResult)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override void WriteByte(byte b)
SyncStream(Stream stream)
override int WriteTimeout
override int Read(byte[] bytes, int offset, int count)
override void Dispose(bool disposing)
override void SetLength(long length)
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override int Read(Span< byte > buffer)
override void Write(byte[] bytes, int offset, int count)
override void Write(ReadOnlySpan< byte > buffer)
override ValueTask DisposeAsync()
static async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
virtual void Dispose(bool disposing)
Task CopyToAsync(Stream destination, int bufferSize)
bool HasOverriddenBeginEndRead()
static void ValidateBufferArguments(byte[] buffer, int offset, int count)
Task BeginEndWriteAsync(byte[] buffer, int offset, int count)
void SetLength(long value)
bool HasOverriddenBeginEndWrite()
virtual void Write(ReadOnlySpan< byte > buffer)
long Seek(long offset, SeekOrigin origin)
static void RunReadWriteTask(ReadWriteTask readWriteTask)
virtual Task FlushAsync(CancellationToken cancellationToken)
static void ValidateCopyToArguments(Stream destination, int bufferSize)
Task WriteAsync(byte[] buffer, int offset, int count)
virtual void EndWrite(IAsyncResult asyncResult)
int Read(byte[] buffer, int offset, int count)
virtual int Read(Span< byte > buffer)
virtual void CopyTo(Stream destination, int bufferSize)
void CopyTo(Stream destination)
Task< int > BeginReadInternal(byte[] buffer, int offset, int count, AsyncCallback callback, object state, bool serializeAsynchronously, bool apm)
virtual Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
static Stream Synchronized(Stream stream)
void FinishTrackingAsyncOperation(ReadWriteTask task)
Task< int > ReadAsync(byte[] buffer, int offset, int count)
SemaphoreSlim _asyncActiveSemaphore
Task CopyToAsync(Stream destination, CancellationToken cancellationToken)
virtual void ObjectInvariant()
void Write(byte[] buffer, int offset, int count)
virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
virtual void WriteByte(byte value)
virtual WaitHandle CreateWaitHandle()
virtual Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
Task BeginWriteInternal(byte[] buffer, int offset, int count, AsyncCallback callback, object state, bool serializeAsynchronously, bool apm)
virtual ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
Task< int > BeginEndReadAsync(byte[] buffer, int offset, int count)
virtual int EndRead(IAsyncResult asyncResult)
static readonly Stream Null
static void RunReadWriteTaskWhenReady(Task asyncWaiter, ReadWriteTask readWriteTask)
Task CopyToAsync(Stream destination)
SemaphoreSlim EnsureAsyncActiveSemaphoreInitialized()
virtual ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
virtual ValueTask DisposeAsync()
virtual Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
static byte Min(byte val1, byte val2)
static string ArgumentOutOfRange_NeedPosNum
static string IO_StreamTooLong
static string InvalidOperation_TimeoutsNotSupported
static void RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
static ? ExecutionContext Capture()
static int CompareExchange(ref int location1, int value, int comparand)
static TaskScheduler Default
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
static void End(IAsyncResult asyncResult)
Task ContinueWith(Action< Task< TResult > > continuationAction)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
void AddCompletionAction(ITaskCompletionAction action, bool addBeforeOthers=false)
static new TaskFactory< TResult > Factory
void ScheduleAndStart(bool needsProtection)
static Task FromCanceled(CancellationToken cancellationToken)
static Task CompletedTask
new TaskAwaiter< TResult > GetAwaiter()
static bool Read(ref bool location)
static void ThrowNotSupportedException_UnwritableStream()
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowInvalidOperationException()
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowObjectDisposedException_StreamClosed(string objectName)
static void ThrowNotSupportedException_UnreadableStream()
void Invoke(Task completingTask)
delegate void ContextCallback(object? state)
void CopyTo(Span< T > destination)
static CancellationToken None
static ValueTask FromCanceled(CancellationToken cancellationToken)
static ValueTask FromException(Exception exception)