Command execution, CreateContainer command WIP

This commit is contained in:
2022-05-23 18:12:22 +02:00
parent 6b3a8f7127
commit d4bd9d3ba1
29 changed files with 499 additions and 26 deletions

View File

@@ -0,0 +1,34 @@
using FileTime.Core.Command;
namespace FileTime.Core.Timeline;
public class LocalCommandExecutor : ILocalCommandExecutor
{
private readonly ICommandRunner _commandRunner;
public event EventHandler<ICommand> CommandFinished;
public LocalCommandExecutor(ICommandRunner commandRunner)
{
_commandRunner = commandRunner;
}
public void ExecuteCommand(ICommand command)
{
var context = new CommandRunnerContext(command);
var thread = new Thread(new ParameterizedThreadStart(RunCommand));
thread.Start(context);
}
private async void RunCommand(object? contextObj)
{
if (contextObj is not CommandRunnerContext context)
throw new ArgumentException($"Parameter must be of type {typeof(CommandRunnerContext)}");
try
{
await _commandRunner.RunCommandAsync(context.Command);
}
catch(Exception ex){}
CommandFinished.Invoke(this, context.Command);
}
}