Example #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);
        }
Example #2
0
 protected override void Dispose(bool disposing)
 {
     Songs.Clear();
     Originals.Clear();
     Covers.Clear();
     Aliases.Clear();
     Songs     = null;
     Originals = null;
     Covers    = null;
     Aliases   = null;
     base.Dispose(disposing);
 }
Example #3
0
 public void RefreshAssets()
 {
     // Copies the Dirty hash set with ToHashSet so that if another thread changes Dirty, it doesn't mess up this loop
     foreach (string assetName in Dirty)
     {
         // If this asset hasn't failed to refresh and it's been loaded and it successfully merges (will attempt to load only if the other two are true)
         if (!Failed.Contains(assetName) && Assets.ContainsKey(assetName) && !this.Merge(assetName, Originals.GetDefault(assetName, null)))
         {
             ModEntry.INSTANCE.Monitor.Log($"Failed to merge {assetName}. Will not try to merge it again.", LogLevel.Warn);
             Failed.Add(assetName);
         }
     }
     Dirty.Clear();
 }