2using System.Threading.Tasks;
34 TaskCompletionSource<int> Result =
new TaskCompletionSource<int>();
36 return await Result.Task;
58 TaskCompletionSource<int> Result =
new TaskCompletionSource<int>();
60 return await Result.Task;
80 public static int Read(
char[] buffer,
int index,
int count)
82 return ReadAsync(buffer, index, count).Result;
101 public static async Task<int>
ReadAsync(
char[] buffer,
int index,
int count)
103 CheckArguments(buffer, index, count);
105 TaskCompletionSource<int> Result =
new TaskCompletionSource<int>();
107 return await Result.Task;
112 private static void CheckArguments(Array buffer,
int index,
int count)
115 throw new ArgumentNullException(nameof(buffer));
118 throw new ArgumentOutOfRangeException(nameof(index));
121 throw new ArgumentOutOfRangeException(nameof(count));
123 if (index > buffer.Length)
124 throw new ArgumentException(nameof(index));
126 if (index + count > buffer.Length)
127 throw new ArgumentException(nameof(count));
141 public static int ReadBlock(
char[] buffer,
int index,
int count)
164 public static async Task<int>
ReadBlockAsync(
char[] buffer,
int index,
int count)
166 CheckArguments(buffer, index, count);
168 TaskCompletionSource<int> Result =
new TaskCompletionSource<int>();
170 return await Result.Task;
192 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
194 return await Result.Task;
219 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
221 return await Result.Task;
239 public static ConsoleKeyInfo
ReadKey(
bool intercept)
259 TaskCompletionSource<ConsoleKeyInfo> Result =
new TaskCompletionSource<ConsoleKeyInfo>();
261 return await Result.Task;
263 return new ConsoleKeyInfo();
Serializes input from System.Console.In, and assures modules are not dead-locked in case the Console ...
static ConsoleKeyInfo ReadKey()
Reads a key press
static string ReadLine()
Reads a line of characters from the text reader and returns the data as a string.
static async Task< int > ReadAsync(char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current text reader asynchronously and writes...
static async Task< string > ReadLineAsync()
Reads a line of characters asynchronously and returns the data as a string.
static Task< ConsoleKeyInfo > ReadKeyAsync()
Reads a key press
static async Task< ConsoleKeyInfo > ReadKeyAsync(bool intercept)
Reads a key press
static string ReadToEnd()
Reads all characters from the current position to the end of the text reader and returns them as one ...
static async Task< int > PeekAsync()
Reads the next character without changing the state of the reader or the character source....
static int Peek()
Reads the next character without changing the state of the reader or the character source....
static async Task< int > ReadBlockAsync(char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current text reader asynchronously and writes...
static async Task< string > ReadToEndAsync()
Reads all characters from the current position to the end of the text reader asynchronously and retur...
static int Read()
Reads the next character from the text reader and advances the character position by one character.
static int ReadBlock(char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current text reader and writes the data to a ...
static ConsoleKeyInfo ReadKey(bool intercept)
Reads a key press
static async Task< int > ReadAsync()
Reads the next character from the text reader and advances the character position by one character.
static int Read(char[] buffer, int index, int count)
Reads a specified maximum number of characters from the current reader and writes the data to a buffe...
Peeks a character from the console.
Reads a block of characters from the console.
Reads a character from the console.
Reads characters from the console.
Reads a key from the console.
Reads a line from the console.
Reads a line from the console.
Processes console tasks, such as input and output, in a serialized asynchronous manner.
static Task< bool > Queue(WorkItem Work)
Queues a work item.