Skip to content

v1.6.2 Cancellable Read()

Compare
Choose a tag to compare
@tbm0115 tbm0115 released this 03 Feb 20:52
· 5 commits to master since this release
808bbb4

What's Changed

  • Implemented CancellationToken on Read() by @tbm0115 in #35

This update allows implementers to call Consoul.Read() and include a CancellationToken to cancel the read operation at anytime. For example:

using(var canceller = new CancellationTokenSource()) {
  canceller.CancelAfter(TimeSpan.FromSeconds(5));
  canceller.Token.Register(() => Consoul.Write("Console.Read() Timed-out!", ConsoleColor.Red));

  // Now wait more than 5 seconds to see the red message in the window
  string userInput = Consoul.Read(canceller.Token);
}
Consoul.Write("Finished!", ConsoleColor.Green);

Full Changelog: v1.6.1...v1.6.2