4using System.Threading.Tasks;
28 private static ConsoleColor foregroundColor =
System.Console.ForegroundColor;
29 private static ConsoleColor backgroundColor =
System.Console.BackgroundColor;
54 System.Console.IsOutputRedirected ||
55 System.Console.IsErrorRedirected ||
56 System.Console.IsInputRedirected ||
57 !Environment.UserInteractive);
101 get => foregroundColor;
104 foregroundColor = value;
114 get => backgroundColor;
117 backgroundColor = value;
126 public static void Write(
string value)
128 if (!
string.IsNullOrEmpty(value))
156 public static void Write(ulong value)
158 Write(value.ToString());
165 public static void Write(uint value)
167 Write(value.ToString());
175 public static void Write(
string format, params
object[] arg)
177 Write(
string.Format(format, arg));
187 public static void Write(
string format,
object arg0,
object arg1,
object arg2)
189 Write(
string.Format(format, arg0, arg1, arg2));
198 public static void Write(
string format,
object arg0,
object arg1)
200 Write(
string.Format(format, arg0, arg1));
208 public static void Write(
string format,
object arg0)
210 Write(
string.Format(format, arg0));
217 public static void Write(
float value)
219 Write(value.ToString());
226 public static void Write(
long value)
228 Write(value.ToString());
237 Write(value.ToString());
244 public static void Write(
double value)
246 Write(value.ToString());
253 public static void Write(decimal value)
255 Write(value.ToString());
264 public static void Write(
char[] buffer,
int index,
int count)
266 Write(
new string(buffer, index, count));
273 public static void Write(
char[] buffer)
275 Write(
new string(buffer));
282 public static void Write(
char value)
284 Write(
new string(value, 1));
291 public static void Write(
bool value)
293 Write(value.ToString());
300 public static void Write(
object value)
302 if (!(value is
null))
303 Write(value.ToString());
312 if (!
string.IsNullOrEmpty(value))
329 public static Task
WriteAsync(
char[] buffer,
int index,
int count)
331 return WriteAsync(
new string(buffer, index, count));
417 public static void WriteLine(
string format, params
object[] arg)
429 public static void WriteLine(
string format,
object arg0,
object arg1,
object arg2)
431 WriteLine(
string.Format(format, arg0, arg1, arg2));
440 public static void WriteLine(
string format,
object arg0,
object arg1)
442 WriteLine(
string.Format(format, arg0, arg1));
459 public static void WriteLine(
string format,
object arg0)
506 public static void WriteLine(
char[] buffer,
int index,
int count)
508 WriteLine(
new string(buffer, index, count));
535 if (!(value is
null))
621 public static void Flush(
bool Terminate)
645 TaskCompletionSource<bool> Result =
new TaskCompletionSource<bool>();
656 get =>
new ConsoleOutTextWriter();
662 private class ConsoleOutTextWriter : TextWriter
664 public ConsoleOutTextWriter()
674 public override void Write(
string format, params
object[] arg) =>
ConsoleOut.
Write(format, arg);
675 public override void Write(
string format,
object arg0,
object arg1,
object arg2) =>
ConsoleOut.
Write(format, arg0, arg1, arg2);
676 public override void Write(
string format,
object arg0,
object arg1) =>
ConsoleOut.
Write(format, arg0, arg1);
677 public override void Write(
string format,
object arg0) =>
ConsoleOut.
Write(format, arg0);
684 public override void Write(
char[] buffer,
int index,
int count) =>
ConsoleOut.
Write(buffer, index, count);
689 public override Task WriteAsync(
char[] buffer,
int index,
int count) =>
ConsoleOut.
WriteAsync(buffer, index, count);
694 public override void WriteLine(
string format, params
object[] arg) =>
ConsoleOut.
WriteLine(format, arg);
695 public override void WriteLine(
string format,
object arg0,
object arg1,
object arg2) =>
ConsoleOut.
WriteLine(format, arg0, arg1, arg2);
696 public override void WriteLine(
string format,
object arg0,
object arg1) =>
ConsoleOut.
WriteLine(format, arg0, arg1);
699 public override void WriteLine(
string format,
object arg0) =>
ConsoleOut.
WriteLine(format, arg0);
704 public override void WriteLine(
char[] buffer,
int index,
int count) =>
ConsoleOut.
WriteLine(buffer, index, count);
711 public override Task WriteLineAsync(
char[] buffer,
int index,
int count) =>
ConsoleOut.
WriteLineAsync(buffer, index, count);
Serializes output to System.Console.Out, and assures modules are not dead-locked in case the Console ...
static void Write(long value)
Queues a value to be written to the console output.
static void WriteLine(string format, object arg0, object arg1)
Queues a value to be written to the console output.
static void Write(string format, params object[] arg)
Queues a value to be written to the console output.
static async Task FlushAsync(bool Terminate)
Asynchronously clears all buffers for the current writer and causes any buffered data to be written t...
static bool HasConsole
Checks if the console is available.
static Encoding Encoding
The character encoding in which the output is written.
static void Write(CustomWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
Queues a custom writer to the console output.
static int CursorTop
Top position of cursor.
static void WriteLine(bool value)
Queues a value to be written to the console output.
static void WriteLine(decimal value)
Queues a value to be written to the console output.
static void Write(uint value)
Queues a value to be written to the console output.
static void Write(bool value)
Queues a value to be written to the console output.
static int WindowHeight
Height of window.
static void Write(string format, object arg0)
Queues a value to be written to the console output.
static void WriteLine(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static int CursorSize
Size of cursor.
static Task WriteLineAsync()
Queues a value to be written to the console output.
static ConsoleColor BackgroundColor
Console background color.
static void Write(string value)
Queues a value to be written to the console output.
static void WriteLine(double value)
Queues a value to be written to the console output.
static Task FlushAsync()
Asynchronously clears all buffers for the current writer and causes any buffered data to be written t...
static void Flush(bool Terminate)
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
static void Write(object value)
Queues a value to be written to the console output.
static TextWriter Writer
Provides a TextWriter instance, that writes to ConsoleOut.
static void WriteLine(string value)
Queues a value to be written to the console output.
static int WindowLeft
Left edge of window.
static void WriteLine(int value)
Queues a value to be written to the console output.
static async Task WriteAsync(string value)
Queues a value to be written to the console output.
static async Task WriteAsync(CustomAsyncWriter Writer, ConsoleColor? ForegroundColor, ConsoleColor? BackgroundColor)
Queues a custom writer to the console output.
static void Write(double value)
Queues a value to be written to the console output.
static void WriteLine(char value)
Queues a value to be written to the console output.
static void Write(char value)
Queues a value to be written to the console output.
static int CursorLeft
Left position of cursor.
static void Write(ulong value)
Queues a value to be written to the console output.
static void Write(int value)
Queues a value to be written to the console output.
static void WriteLine(ulong value)
Queues a value to be written to the console output.
static void Write(string format, object arg0, object arg1, object arg2)
Queues a value to be written to the console output.
static ConsoleColor ForegroundColor
Console foreground color.
static Task WriteLineAsync(char[] buffer)
Queues a value to be written to the console output.
static void WriteLine()
Queues a value to be written to the console output.
static Task WriteAsync(char value)
Queues a value to be written to the console output.
static void WriteLine(object value)
Queues a value to be written to the console output.
static void WriteLine(string format, params object[] arg)
Queues a value to be written to the console output.
static void WriteLine(string format, object arg0, object arg1, object arg2)
Queues a value to be written to the console output.
static string NewLine
The line terminator string for the current TextWriter.
static Task WriteAsync(CustomAsyncWriter Writer)
Queues a custom writer to the console output.
static Task WriteAsync(char[] buffer)
Queues a value to be written to the console output.
static int WindowTop
Top edge of window.
static void Write(decimal value)
Queues a value to be written to the console output.
static void Write(float value)
Queues a value to be written to the console output.
static void Write(CustomWriter Writer)
Queues a custom writer to the console output.
static void Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
static void Beep()
Emits a Beep sounds.
static void WriteLine(long value)
Queues a value to be written to the console output.
static int WindowWidth
Width of window.
static void WriteLine(char[] buffer)
Queues a value to be written to the console output.
static void WriteLine(float value)
Queues a value to be written to the console output.
static void WriteLine(string format, object arg0)
Queues a value to be written to the console output.
static Task WriteLineAsync(char value)
Queues a value to be written to the console output.
static async Task WriteLineAsync(string value)
Queues a value to be written to the console output.
static void Write(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static void Write(char[] buffer)
Queues a value to be written to the console output.
static Task WriteLineAsync(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static void WriteLine(uint value)
Queues a value to be written to the console output.
static IFormatProvider FormatProvider
Gets an object that controls formatting.
static Task WriteAsync(char[] buffer, int index, int count)
Queues a value to be written to the console output.
static void Write(string format, object arg0, object arg1)
Queues a value to be written to the console output.
Changes the console background color.
Used to signal end of queue has been reached.
Changes the console foreground color.
Writes a string to the console, appending a newline at the end.
Writes a string to the console
Processes console tasks, such as input and output, in a serialized asynchronous manner.
static Task< bool > Forward(WorkItem Work)
Forwards a work item for processing.
static bool Terminating
If the console worker is being terminated.
Represents an asynchronous operation to be performed.
Task< bool > Wait()
Waits for the item to be processed.
delegate void CustomWriter(TextWriter Output)
Delegate for custom writers.
delegate Task CustomAsyncWriter(TextWriter Output)
Delegate for asynchronous custom writers.