diff --git a/src/Consolonia.Core/Infrastructure/ConsoloniaLifetime.cs b/src/Consolonia.Core/Infrastructure/ConsoloniaLifetime.cs index b7289609..0954d8d9 100644 --- a/src/Consolonia.Core/Infrastructure/ConsoloniaLifetime.cs +++ b/src/Consolonia.Core/Infrastructure/ConsoloniaLifetime.cs @@ -1,41 +1,41 @@ -using System; using System.Threading; using System.Threading.Tasks; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Threading; -namespace Consolonia.Core.Infrastructure; - -public class ConsoloniaLifetime : ClassicDesktopStyleApplicationLifetime +namespace Consolonia.Core.Infrastructure { - /// - /// returned task indicates that console is successfully paused - /// - public Task DisconnectFromConsoleAsync(CancellationToken cancellationToken) + public class ConsoloniaLifetime : ClassicDesktopStyleApplicationLifetime { - var taskToWaitFor = new TaskCompletionSource(); - cancellationToken.Register(() => taskToWaitFor.SetResult()); + /// + /// returned task indicates that console is successfully paused + /// + public Task DisconnectFromConsoleAsync(CancellationToken cancellationToken) + { + var taskToWaitFor = new TaskCompletionSource(); + cancellationToken.Register(() => taskToWaitFor.SetResult()); - var mainWindowPlatformImpl = (ConsoleWindow)MainWindow.PlatformImpl; - IConsole console = mainWindowPlatformImpl.Console; + var mainWindowPlatformImpl = (ConsoleWindow)MainWindow.PlatformImpl; + IConsole console = mainWindowPlatformImpl.Console; - Task pauseTask = taskToWaitFor.Task; + Task pauseTask = taskToWaitFor.Task; - console.PauseIO(pauseTask); + console.PauseIO(pauseTask); - pauseTask.ContinueWith(_ => - { - mainWindowPlatformImpl.Console.ClearOutput(); - - Dispatcher.UIThread.Post(() => + pauseTask.ContinueWith(_ => { - MainWindow.InvalidateVisual(); - }); - }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default); + mainWindowPlatformImpl.Console.ClearOutput(); - return Dispatcher.UIThread.InvokeAsync(() => - { + Dispatcher.UIThread.Post(() => + { + MainWindow.InvalidateVisual(); + }); + }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default); + + return Dispatcher.UIThread.InvokeAsync(() => + { - }); + }); + } } } \ No newline at end of file diff --git a/src/Consolonia.sln.DotSettings b/src/Consolonia.sln.DotSettings index 3477ac54..57ae322c 100644 --- a/src/Consolonia.sln.DotSettings +++ b/src/Consolonia.sln.DotSettings @@ -4,6 +4,7 @@ Default Default Default + BlockScoped GDP UI XY