From 4ae65e91df33c6a935fb85e63713a66188728f21 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Mon, 28 Mar 2022 13:50:09 -0500 Subject: [PATCH] Run GetShowsAsync in the background This allows for faster startup because initializing and checking the cache doesn't block the UI thread. --- src/Mobile/ViewModels/DiscoverViewModel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Mobile/ViewModels/DiscoverViewModel.cs b/src/Mobile/ViewModels/DiscoverViewModel.cs index 3960beb..d36f3d5 100644 --- a/src/Mobile/ViewModels/DiscoverViewModel.cs +++ b/src/Mobile/ViewModels/DiscoverViewModel.cs @@ -49,7 +49,9 @@ public class DiscoverViewModel : BaseViewModel private async Task FetchAsync() { - var podcastsModels = await showsService.GetShowsAsync(); + // run GetShowsAsync in the background, so things get initialized in the background + // like checking the cache and the web request + var podcastsModels = await Task.Run(() => showsService.GetShowsAsync()); if (podcastsModels == null) {