Пример #1
0
        protected override async Task <bool> LoadAsync()
        {
            if (IsLoaded || IsBusy)
            {
                return(false);
            }
            IsBusy     = true;
            IsBusyText = "Loading Song History...";
            await Task.Run(async() =>
            {
                var randomSetlist = await WebApiClientService.GetSongsAsync();
                return(randomSetlist);
            })
            .ContinueWith(task =>
            {
                try
                {
                    if (!task.IsFaulted && task.Result != null)
                    {
                        foreach (var song in task.Result.OrderBy(s => s.SongName))
                        {
                            Songs.Add(song);
                            if (song.IsAlias)
                            {
                                Aliases.Add(song);
                            }

                            if (song.IsCover)
                            {
                                Covers.Add(song);
                            }

                            if (song.IsOriginal)
                            {
                                Originals.Add(song);
                            }
                        }
                    }
                    else
                    {
                        AlertManagerService.ShowAlert("Error Occurred Loading Song History", task.Exception.ToString());
                    }
                }
                catch (Exception e)
                {
                    AlertManagerService.ShowAlert("Error Occurred Loading Song History", e.ToString());
                }
                finally
                {
                    IsBusy   = false;
                    IsLoaded = true;
                    task.Dispose();
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(true);
        }
Пример #2
0
        protected override async Task <bool> LoadAsync()
        {
            if (IsLoaded || IsBusy)
            {
                return(false);
            }
            IsBusy     = true;
            IsBusyText = "Loading Upcoming Shows...";
            await Task.Run(async() =>
            {
                var randomSetlist = await WebApiClientService.GetUpcomingShowsAsync();
                return(randomSetlist);
            })
            .ContinueWith(task =>
            {
                try
                {
                    if (!task.IsFaulted && task.Result != null)
                    {
                        foreach (var show in task.Result)
                        {
                            UpcomingShows.Add(show);
                        }
                    }
                    else
                    {
                        AlertManagerService.ShowAlert("Error Occurred Loading Upcoming Shows", task.Exception.ToString());
                    }
                }
                catch (Exception e)
                {
                    AlertManagerService.ShowAlert("Error Occurred Loading Upcoming Shows", e.ToString());
                }
                finally
                {
                    IsBusy   = false;
                    IsLoaded = true;
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(true);
        }