mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Await close event from non-ui thread
This commit is contained in:
parent
8aebf958aa
commit
122887e6a6
3 changed files with 15 additions and 7 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
|
|
@ -64,13 +65,18 @@ namespace Flow.Launcher.Core
|
|||
}
|
||||
}
|
||||
|
||||
private new void Close()
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
if (!Application.Current.Dispatcher.CheckAccess())
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(Close);
|
||||
await Application.Current.Dispatcher.InvokeAsync(Close);
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private new void Close()
|
||||
{
|
||||
if (_isClosed)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
namespace Flow.Launcher.Plugin;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flow.Launcher.Plugin;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for progress box
|
||||
|
|
@ -16,5 +18,5 @@ public interface IProgressBoxEx
|
|||
/// <summary>
|
||||
/// Close progress box.
|
||||
/// </summary>
|
||||
public void Close();
|
||||
public Task CloseAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
if (downloadCancelled)
|
||||
return;
|
||||
else
|
||||
prgBox?.Close();
|
||||
await prgBox?.CloseAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -217,7 +217,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
catch (HttpRequestException e)
|
||||
{
|
||||
// force close progress box
|
||||
prgBox?.Close();
|
||||
await prgBox?.CloseAsync();
|
||||
|
||||
// show error message
|
||||
Context.API.ShowMsgError(
|
||||
|
|
@ -230,7 +230,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
catch (Exception e)
|
||||
{
|
||||
// force close progress box
|
||||
prgBox?.Close();
|
||||
await prgBox?.CloseAsync();
|
||||
|
||||
// show error message
|
||||
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue