Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ConsoleInReadBlock.cs
1using System;
2using System.Threading;
3using System.Threading.Tasks;
5
7{
12 {
13 private readonly TaskCompletionSource<int> result;
14 private readonly char[] buffer;
15 private readonly int index;
16 private readonly int count;
17
31 public ConsoleInReadBlock(char[] Buffer, int Index, int Count, TaskCompletionSource<int> Result)
32 {
33 this.buffer = Buffer;
34 this.index = Index;
35 this.count = Count;
36 this.result = Result;
37 }
38
43 public override async Task Execute(CancellationToken Cancel)
44 {
45 try
46 {
47 int Result = await System.Console.In.ReadBlockAsync(this.buffer, this.index, this.count);
48 this.result.TrySetResult(Result);
49 }
50 catch (Exception ex)
51 {
52 this.result.TrySetException(ex);
53 }
54 }
55 }
56}
Reads a block of characters from the console.
ConsoleInReadBlock(char[] Buffer, int Index, int Count, TaskCompletionSource< int > Result)
Reads a block of characters from the console.
override async Task Execute(CancellationToken Cancel)
Executes the console operation.
Represents an asynchronous operation to be performed.
Definition: WorkItem.cs:10