Skip to content

Commit

Permalink
Merge tag '7.0.5' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed Dec 20, 2024
2 parents e8e337f + a95b8a7 commit b239b7c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using Catel.IoC;
using Catel.Logging;
using Catel.Services;
using Catel.Windows.Threading;
using Orchestra.Services;

public abstract class ApplicationWatcherBase
Expand All @@ -18,7 +18,7 @@ public abstract class ApplicationWatcherBase
protected static readonly IDispatcherService DispatcherService;
protected static readonly IMainWindowService MainWindowService;

private static readonly DispatcherTimer DispatcherTimer;
private static readonly DispatcherTimerEx DispatcherTimer;
private static readonly Queue<Action<Window>> ShellActivatedActions;
private static readonly object Lock = new object();

Expand All @@ -30,7 +30,7 @@ static ApplicationWatcherBase()
DispatcherService = serviceLocator.ResolveRequiredType<IDispatcherService>();
MainWindowService = serviceLocator.ResolveRequiredType<IMainWindowService>();

DispatcherTimer = new DispatcherTimer();
DispatcherTimer = new DispatcherTimerEx(DispatcherService);
DispatcherTimer.Interval = TimeSpan.FromMilliseconds(5);
DispatcherTimer.Tick += async (sender, e) => await EnsureMainWindowAsync();
DispatcherTimer.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,22 @@ private static async Task HandleClosingErrorAsync(Window window, Exception ex)

if (await MessageService.ShowAsync(closingDetails.Message, "Error", messageButton, MessageImage.Error) == MessageResult.OK)
{
await CloseWindowAsync(window).ConfigureAwait(false);
await CloseWindowAsync(window);
}
}

private static async Task CloseWindowAsync(Window window)
{
await DispatcherService.InvokeAsync(window.Close).ConfigureAwait(false);
try
{
// Note: always use window dispatcher
await window.Dispatcher.InvokeAsync(window.Close);
//await DispatcherService.InvokeAsync(window.Close).ConfigureAwait(false);
}
catch (Exception)
{
// ignore
}
}

private static void NotifyClosingCanceled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private async Task RunOnWindowClosingAndWaitForFinishAsync(TestCloseApplicationW
ArgumentNullException.ThrowIfNull(watcher);

bool isWatcherCompleted = false;

using (var cts = new CancellationTokenSource(timeout))
{
// Use a semaphore to prevent the [TestMethod] from returning prematurely.
Expand Down

0 comments on commit b239b7c

Please sign in to comment.