Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadAsyncCore()

unsafe ValueTask< int > System.IO.Pipes.PipeStream.ReadAsyncCore ( Memory< byte > buffer,
CancellationToken cancellationToken )
inlineprivate

Definition at line 903 of file PipeStream.cs.

904 {
905 ReadWriteValueTaskSource readWriteValueTaskSource = Interlocked.Exchange(ref _reusableReadValueTaskSource, null) ?? new ReadWriteValueTaskSource(this, isWrite: false);
906 try
907 {
908 readWriteValueTaskSource.PrepareForOperation(buffer);
909 if (global::Interop.Kernel32.ReadFile(_handle, (byte*)readWriteValueTaskSource._memoryHandle.Pointer, buffer.Length, IntPtr.Zero, readWriteValueTaskSource._overlapped) == 0)
910 {
911 int lastPInvokeError = Marshal.GetLastPInvokeError();
912 switch (lastPInvokeError)
913 {
914 case 997:
915 readWriteValueTaskSource.RegisterForCancellation(cancellationToken);
916 break;
917 case 109:
918 case 233:
919 State = PipeState.Broken;
920 readWriteValueTaskSource._overlapped->InternalLow = IntPtr.Zero;
921 readWriteValueTaskSource.Dispose();
922 UpdateMessageCompletion(completion: true);
923 return new ValueTask<int>(0);
924 default:
925 readWriteValueTaskSource.Dispose();
927 case 234:
928 break;
929 }
930 }
931 }
932 catch
933 {
934 readWriteValueTaskSource.Dispose();
935 throw;
936 }
937 readWriteValueTaskSource.FinishedScheduling();
938 return new ValueTask<int>(readWriteValueTaskSource, readWriteValueTaskSource.Version);
939 }
void UpdateMessageCompletion(bool completion)
ReadWriteValueTaskSource _reusableReadValueTaskSource
static Exception GetExceptionForWin32Error(int errorCode, string path="")
static int Exchange(ref int location1, int value)
static ValueTask FromException(Exception exception)
Definition ValueTask.cs:190

References System.IO.Pipes.PipeStream._handle, System.IO.Pipes.PipeStream.PipeValueTaskSource._memoryHandle, System.IO.Pipes.PipeStream.PipeValueTaskSource._overlapped, System.IO.Pipes.PipeStream._reusableReadValueTaskSource, System.buffer, System.cancellationToken, System.IO.Pipes.PipeStream.PipeValueTaskSource.Dispose(), System.Threading.Interlocked.Exchange(), System.IO.Pipes.PipeStream.PipeValueTaskSource.FinishedScheduling(), System.Threading.Tasks.ValueTask< TResult >.FromException(), System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), System.Threading.NativeOverlapped.InternalLow, System.Buffers.MemoryHandle.Pointer, System.IO.Pipes.PipeStream.PipeValueTaskSource.PrepareForOperation(), System.IO.Pipes.PipeStream.PipeValueTaskSource.RegisterForCancellation(), System.IO.Pipes.PipeStream.UpdateMessageCompletion(), System.IO.Pipes.PipeStream.PipeValueTaskSource.Version, and System.IntPtr.Zero.

Referenced by System.IO.Pipes.PipeStream.ReadAsync(), and System.IO.Pipes.PipeStream.ReadAsync().