mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-12-29 09:18:05 +01:00
* Less cluttered solution layout. * Move examples to a repository of its own. * Move Roslyn analyzer to a repository of its own. * Enable central package management. * Clean up csproj files. * Add README file to NuGet packages.
29 lines
724 B
C#
29 lines
724 B
C#
namespace Spectre.Console.Tests.Data;
|
|
|
|
public sealed class AsynchronousCommand : AsyncCommand<AsynchronousCommandSettings>
|
|
{
|
|
private readonly IAnsiConsole _console;
|
|
|
|
public AsynchronousCommand(IAnsiConsole console)
|
|
{
|
|
_console = console;
|
|
}
|
|
|
|
public async override Task<int> ExecuteAsync(CommandContext context, AsynchronousCommandSettings settings)
|
|
{
|
|
// Simulate a long running asynchronous task
|
|
await Task.Delay(200);
|
|
|
|
if (settings.ThrowException)
|
|
{
|
|
throw new Exception($"Throwing exception asynchronously");
|
|
}
|
|
else
|
|
{
|
|
_console.WriteLine($"Finished executing asynchronously");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|