System.ConsolePal.Write C# (CSharp) Method

Write() private static method

private static Write ( SafeFileHandle fd, byte bufPtr, int count ) : void
fd SafeFileHandle
bufPtr byte
count int
return void
        private static unsafe void Write(SafeFileHandle fd, byte* bufPtr, int count)
        {
            while (count > 0)
            {
                int bytesWritten = Interop.Sys.Write(fd, bufPtr, count);
                if (bytesWritten < 0)
                {
                    Interop.ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo();
                    if (errorInfo.Error == Interop.Error.EPIPE)
                    {
                        // Broken pipe... likely due to being redirected to a program
                        // that ended, so simply pretend we were successful.
                        return;
                    }
                    else
                    {
                        // Something else... fail.
                        throw Interop.GetExceptionForIoErrno(errorInfo);
                    }
                }

                count -= bytesWritten;
                bufPtr += bytesWritten;
            }
        }

Same methods

ConsolePal::Write ( SafeFileHandle fd, byte buffer, int offset, int count ) : void

Usage Example

示例#1
0
            public override void Write(byte[] buffer, int offset, int count)
            {
                ValidateWrite(buffer, offset, count);

                ConsolePal.Write(_handle, buffer, offset, count);
            }