Skip to content

Commit 122887e

Browse files
committed
Await close event from non-ui thread
1 parent 8aebf95 commit 122887e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Flow.Launcher.Core/ProgressBoxEx.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading.Tasks;
23
using System.Windows;
34
using System.Windows.Input;
45
using Flow.Launcher.Infrastructure.Logger;
@@ -64,13 +65,18 @@ public void ReportProgress(double progress)
6465
}
6566
}
6667

67-
private new void Close()
68+
public async Task CloseAsync()
6869
{
6970
if (!Application.Current.Dispatcher.CheckAccess())
7071
{
71-
Application.Current.Dispatcher.Invoke(Close);
72+
await Application.Current.Dispatcher.InvokeAsync(Close);
7273
}
7374

75+
Close();
76+
}
77+
78+
private new void Close()
79+
{
7480
if (_isClosed)
7581
{
7682
return;

Flow.Launcher.Plugin/IProgressBoxEx.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Flow.Launcher.Plugin;
1+
using System.Threading.Tasks;
2+
3+
namespace Flow.Launcher.Plugin;
24

35
/// <summary>
46
/// Interface for progress box
@@ -16,5 +18,5 @@ public interface IProgressBoxEx
1618
/// <summary>
1719
/// Close progress box.
1820
/// </summary>
19-
public void Close();
21+
public Task CloseAsync();
2022
}

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
196196
if (downloadCancelled)
197197
return;
198198
else
199-
prgBox?.Close();
199+
await prgBox?.CloseAsync();
200200
}
201201
else
202202
{
@@ -217,7 +217,7 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
217217
catch (HttpRequestException e)
218218
{
219219
// force close progress box
220-
prgBox?.Close();
220+
await prgBox?.CloseAsync();
221221

222222
// show error message
223223
Context.API.ShowMsgError(
@@ -230,7 +230,7 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
230230
catch (Exception e)
231231
{
232232
// force close progress box
233-
prgBox?.Close();
233+
await prgBox?.CloseAsync();
234234

235235
// show error message
236236
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),

0 commit comments

Comments
 (0)