Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ConsoleInReadKey.cs
1using System;
2using System.Threading;
3using System.Threading.Tasks;
5
7{
12 {
13 private readonly TaskCompletionSource<ConsoleKeyInfo> result;
14 private readonly bool intercept;
15
21 public ConsoleInReadKey(bool Intercept, TaskCompletionSource<ConsoleKeyInfo> Result)
22 {
23 this.result = Result;
24 this.intercept = Intercept;
25 }
26
31 public override Task Execute(CancellationToken Cancel)
32 {
33 try
34 {
35 ConsoleKeyInfo Result = System.Console.ReadKey(this.intercept);
36 this.result.TrySetResult(Result);
37 }
38 catch (Exception ex)
39 {
40 this.result.TrySetException(ex);
41 }
42
43 return Task.CompletedTask;
44 }
45 }
46}
override Task Execute(CancellationToken Cancel)
Executes the console operation.
ConsoleInReadKey(bool Intercept, TaskCompletionSource< ConsoleKeyInfo > Result)
Reads a key from the console.
Represents an asynchronous operation to be performed.
Definition: WorkItem.cs:10