Skip to content

Commit

Permalink
Merge pull request #2448 from unoplatform/dev/dr/refThreading
Browse files Browse the repository at this point in the history
fix(mvux): Fix possible cross threading exception in refresh command
  • Loading branch information
dr1rrb authored Jul 19, 2024
2 parents e2d1783 + bdf3254 commit 066df73
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Uno.Extensions.Reactive.UI/View/FeedView.Refresh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,24 @@ public void Execute(object? parameter)
{
try
{
subscription.RequestRefresh(() => IsExecuting = false);
subscription.RequestRefresh(EndExecution);
}
catch (Exception error)
{
if (this.Log().IsEnabled(LogLevel.Warning))
{
this.Log().Warn(error, "Failed to send a refresh request");
}
IsExecuting = false;
EndExecution();
}
});

void EndExecution()
#if WINUI
=> _ = _view.DispatcherQueue.TryEnqueue(() => IsExecuting = false);
#else
=> _ = _view.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => IsExecuting = false);
#endif
}
}
}
Expand Down

0 comments on commit 066df73

Please sign in to comment.