Skip to content

Commit 8aebf95

Browse files
committed
Check ui thread when calling close function & Update documents
1 parent aff6b1a commit 8aebf95

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Flow.Launcher.Core/ProgressBoxEx.xaml.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,16 @@ public void ReportProgress(double progress)
6666

6767
private new void Close()
6868
{
69+
if (!Application.Current.Dispatcher.CheckAccess())
70+
{
71+
Application.Current.Dispatcher.Invoke(Close);
72+
}
73+
6974
if (_isClosed)
7075
{
7176
return;
7277
}
73-
78+
7479
base.Close();
7580
_isClosed = true;
7681
}

Flow.Launcher.Plugin/IProgressBoxEx.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
public interface IProgressBoxEx
77
{
88
/// <summary>
9-
/// Show progress box. It should be called from the main ui thread.
9+
/// Show progress box.
1010
/// </summary>
1111
/// <param name="progress">
1212
/// Progress value. Should be between 0 and 100. When progress is 100, the progress box will be closed.
1313
/// </param>
1414
public void ReportProgress(double progress);
1515

1616
/// <summary>
17-
/// Close progress box. It should be called from the main ui thread.
17+
/// Close progress box.
1818
/// </summary>
1919
public void Close();
2020
}

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

Lines changed: 3 additions & 11 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-
CleanupProgressBoxEx(prgBox);
199+
prgBox?.Close();
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-
CleanupProgressBoxEx(prgBox);
220+
prgBox?.Close();
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-
CleanupProgressBoxEx(prgBox);
233+
prgBox?.Close();
234234

235235
// show error message
236236
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
@@ -256,14 +256,6 @@ internal async Task InstallOrUpdateAsync(UserPlugin plugin)
256256
}
257257
}
258258

259-
private static void CleanupProgressBoxEx(IProgressBoxEx prgBox)
260-
{
261-
Application.Current.Dispatcher.Invoke(() =>
262-
{
263-
prgBox?.Close();
264-
});
265-
}
266-
267259
internal async ValueTask<List<Result>> RequestUpdateAsync(string search, CancellationToken token,
268260
bool usePrimaryUrlOnly = false)
269261
{

0 commit comments

Comments
 (0)