Class InputImpl<TInputRecord>
Base class for reading console input in perpetual loop. The Peek() and Read() methods are executed on the input thread created by StartInputTaskAsync(IApplication).
public abstract class InputImpl<TInputRecord> : IInput<TInputRecord>, IDisposable
Type Parameters
TInputRecord
- Inheritance
-
InputImpl<TInputRecord>
- Implements
-
IInput<TInputRecord>
- Derived
- Inherited Members
Properties
- ExternalCancellationTokenSource
Gets or sets an external cancellation token source that can stop the Run(CancellationToken) loop in addition to the
runCancellationTokenpassed to Run(CancellationToken).
- Now
Determines how to get the current system type, adjust in unit tests to simulate specific timings.
Methods
- Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- Initialize(ConcurrentQueue<TInputRecord>)
Initializes the input reader with the thread-safe queue where read input will be stored.
- Peek()
When implemented in a derived class, returns true if there is data available to read from console.
- Run(CancellationToken)
Runs the input loop, continuously reading input and placing it into the queue provided by Initialize(ConcurrentQueue<TInputRecord>).