IConsoleInput.cs 991 B

1234567891011121314151617181920212223242526272829
  1. using System.Collections.Concurrent;
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// Interface for reading console input indefinitely -
  5. /// i.e. in an infinite loop. The class is responsible only
  6. /// for reading and storing the input in a thread safe input buffer
  7. /// which is then processed downstream e.g. on main UI thread.
  8. /// </summary>
  9. /// <typeparam name="T"></typeparam>
  10. public interface IConsoleInput<T> : IDisposable
  11. {
  12. /// <summary>
  13. /// Initializes the input with a buffer into which to put data read
  14. /// </summary>
  15. /// <param name="inputBuffer"></param>
  16. void Initialize (ConcurrentQueue<T> inputBuffer);
  17. /// <summary>
  18. /// Runs in an infinite input loop.
  19. /// </summary>
  20. /// <param name="token"></param>
  21. /// <exception cref="OperationCanceledException">
  22. /// Raised when token is
  23. /// cancelled. This is the only means of exiting the input.
  24. /// </exception>
  25. void Run (CancellationToken token);
  26. }