Support cancellation of prompts

Closes #417
This commit is contained in:
Patrik Svensson
2021-07-10 21:03:13 +02:00
committed by Phil Scott
parent 884cb8ddd4
commit 5f97f2300c
15 changed files with 117 additions and 26 deletions

View File

@ -12,7 +12,7 @@ namespace Spectre.Console.Testing
public async Task<T> Run<T>(Func<Task<T>> func)
{
return await func();
return await func().ConfigureAwait(false);
}
}
}

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Spectre.Console.Testing
{
@ -74,5 +76,11 @@ namespace Spectre.Console.Testing
return _input.Dequeue();
}
/// <inheritdoc/>
public Task<ConsoleKeyInfo?> ReadKeyAsync(bool intercept, CancellationToken cancellationToken)
{
return Task.FromResult(ReadKey(intercept));
}
}
}