private static WriteAsyncInternal ( |
||
_this | ||
value | char | |
charBuffer | char | |
charPos | int | |
charLen | int | |
coreNewLine | char | |
autoFlush | bool | |
appendNewLine | bool | |
Результат | System.Threading.Tasks.Task |
private static async Task WriteAsyncInternal(StreamWriter _this, char value,
char[] charBuffer, int charPos, int charLen, char[] coreNewLine,
bool autoFlush, bool appendNewLine)
{
if (charPos == charLen)
{
await _this.FlushAsyncInternal(false, false, charBuffer, charPos).ConfigureAwait(false);
Debug.Assert(_this._charPos == 0);
charPos = 0;
}
charBuffer[charPos] = value;
charPos++;
if (appendNewLine)
{
for (int i = 0; i < coreNewLine.Length; i++) // Expect 2 iterations, no point calling BlockCopy
{
if (charPos == charLen)
{
await _this.FlushAsyncInternal(false, false, charBuffer, charPos).ConfigureAwait(false);
Debug.Assert(_this._charPos == 0);
charPos = 0;
}
charBuffer[charPos] = coreNewLine[i];
charPos++;
}
}
if (autoFlush)
{
await _this.FlushAsyncInternal(true, false, charBuffer, charPos).ConfigureAwait(false);
Debug.Assert(_this._charPos == 0);
charPos = 0;
}
_this.CharPos_Prop = charPos;
}
StreamWriter::WriteAsyncInternal ( |
|
StreamWriter::WriteAsyncInternal ( |
public override Task WriteLineAsync(char[] buffer, int index, int count) { if (buffer == null) { throw new ArgumentNullException("buffer", Environment.GetResourceString("ArgumentNull_Buffer")); } if (index < 0) { throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (count < 0) { throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (buffer.Length - index < count) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); } if (this.GetType() != typeof(StreamWriter)) { return(base.WriteLineAsync(buffer, index, count)); } if (this.stream == null) { __Error.WriterClosed(); } this.CheckAsyncTaskInProgress(); Task task = StreamWriter.WriteAsyncInternal(this, buffer, index, count, this.charBuffer, this.charPos, this.charLen, this.CoreNewLine, this.autoFlush, true); this._asyncWriteTask = task; return(task); }