guard terminal methods
This commit is contained in:
@@ -26,16 +26,17 @@
|
||||
{
|
||||
Guard.Against.Null(Project);
|
||||
Guard.Against.Null(Project.RunningOutputChannel, nameof(Project.RunningOutputChannel));
|
||||
if (_terminalDisplayRef is not null) await _terminalDisplayRef.Clear();
|
||||
await InvokeAsync(async () => await OnProjectStarted.InvokeAsync(Project));
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await foreach (var log in Project.RunningOutputChannel.Reader.ReadAllAsync())
|
||||
if (_terminalDisplayRef is not null) await _terminalDisplayRef.Clear();
|
||||
await InvokeAsync(async () => await OnProjectStarted.InvokeAsync(Project));
|
||||
await foreach (var log in Project.RunningOutputChannel.Reader.ReadAllAsync().ConfigureAwait(false))
|
||||
{
|
||||
// Better hope you don't get a log until we get the component ref lol
|
||||
await _terminalDisplayRef.Write(log);
|
||||
await _terminalDisplayRef.Write(log).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e) when (e is not OperationCanceledException)
|
||||
|
||||
@@ -31,17 +31,22 @@
|
||||
|
||||
private HashSet<string> _addons = ["addon-fit"];
|
||||
|
||||
private TaskCompletionSource _firstRenderTask = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public async Task Write(byte[] line)
|
||||
{
|
||||
if (_firstRenderTask.Task.IsCompleted is false) await _firstRenderTask.Task;
|
||||
await _terminalRef.Write(line);
|
||||
}
|
||||
public async Task Write(string line)
|
||||
{
|
||||
if (_firstRenderTask.Task.IsCompleted is false) await _firstRenderTask.Task;
|
||||
await _terminalRef.Write(line);
|
||||
}
|
||||
|
||||
public async Task Clear()
|
||||
{
|
||||
if (_firstRenderTask.Task.IsCompleted is false) await _firstRenderTask.Task;
|
||||
if (_terminalRef is not null)
|
||||
{
|
||||
await _terminalRef.Reset();
|
||||
@@ -52,6 +57,7 @@
|
||||
private async Task OnFirstRender()
|
||||
{
|
||||
await _terminalRef.Addon("addon-fit").InvokeVoidAsync("fit");
|
||||
_firstRenderTask.SetResult();
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user