Skip to content

Commit

Permalink
🔧 Fix(DebugService): Adapt to new Csharpell.Core package
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Jun 19, 2024
1 parent b416e4a commit 8f3ce1e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions KitX Dashboard/ViewModels/DebugWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ public DebugWindowViewModel()
InitEvents();
}

public override void InitCommands()
public sealed override void InitCommands()
{
SubmitCodesCommand = ReactiveCommand.Create<IDocument>(SubmitCodes);

CancelExecutionCommand = ReactiveCommand.Create(() => _cancellationTokenSource?.Cancel());
}

public override void InitEvents()
{

}
public sealed override void InitEvents() { }

internal void SubmitCodes(IDocument doc)
{
Expand All @@ -41,21 +38,27 @@ internal void SubmitCodes(IDocument doc)

_cancellationTokenSource = tokenSource;

Task.Run(async () =>
{
var result = await DebugService.ExecuteCodesAsync(code, tokenSource.Token);
Task.Run(
async () =>
{
var result = await DebugService.ExecuteCodesAsync(
code,
cancellationToken: tokenSource.Token
);
tokenSource.Dispose();
tokenSource.Dispose();
_cancellationTokenSource = null;
_cancellationTokenSource = null;
Dispatcher.UIThread.Invoke(() =>
{
ExecutionResult = result ?? string.Empty;
Dispatcher.UIThread.Invoke(() =>
{
ExecutionResult = result ?? string.Empty;
IsExecuting = false;
});
});
IsExecuting = false;
});
},
tokenSource.Token
);
}

private string _executionResult = string.Empty;
Expand Down

0 comments on commit 8f3ce1e

Please sign in to comment.