Skip to content

Commit

Permalink
+1
Browse files Browse the repository at this point in the history
  • Loading branch information
jinek committed Nov 21, 2023
1 parent 5ea9c7c commit b9f0374
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/Consolonia.Core/Infrastructure/ConsoloniaLifetime.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// returned task indicates that console is successfully paused
/// </summary>
public Task DisconnectFromConsoleAsync(CancellationToken cancellationToken)
public class ConsoloniaLifetime : ClassicDesktopStyleApplicationLifetime
{
var taskToWaitFor = new TaskCompletionSource();
cancellationToken.Register(() => taskToWaitFor.SetResult());
/// <summary>
/// returned task indicates that console is successfully paused
/// </summary>
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(() =>
{

});
});
}
}
}
1 change: 1 addition & 0 deletions src/Consolonia.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/FiltersState/=CodeStyle/@EntryIndexedValue">Default</s:String>
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/FiltersState/=NamingFilter/@EntryIndexedValue">Default</s:String>
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/FiltersState/=SpellingFilter/@EntryIndexedValue">Default</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/NAMESPACE_BODY/@EntryValue">BlockScoped</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GDP/@EntryIndexedValue">GDP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XY/@EntryIndexedValue">XY</s:String>
Expand Down

0 comments on commit b9f0374

Please sign in to comment.