public static void Update() { lock (Lock) { TaskManagerPage.Current.Queue.Submit(new RunTask("Updating application view...", new Task(() => { TitlesChanged?.Invoke(Applications, Titles, Saves); }))); } }
public static void Update() { TaskManagerPage.Current.Queue.Submit(new RunTask("Updating application view...", new Task(() => { Dictionary <ulong, Application> totalApps = new Dictionary <ulong, Application>(); Dictionary <ulong, Title> totalTitles = new Dictionary <ulong, Title>(); Dictionary <string, SaveDataFileSystem> totalSaves = new Dictionary <string, SaveDataFileSystem>(); if (SDTitleView.FS != null) { totalSaves.AddRange(SDTitleView.FS.Saves, true); lock (totalApps) { foreach (KeyValuePair <ulong, Application> kv in SDTitleView.FS.Applications) { ulong titleid = kv.Key; Application app = kv.Value; if (totalApps.ContainsKey(titleid)) { totalApps[titleid].AddTitle(app.Main); totalApps[titleid].AddTitle(app.Patch); foreach (Title title in totalApps[titleid].AddOnContent) { totalApps[titleid].AddTitle(title); } } else { totalApps[titleid] = app; } } totalTitles.AddRange(SDTitleView.FS.Titles, true); } } if (NANDSystemTitleView.FS != null) { totalSaves.AddRange(NANDSystemTitleView.FS.Saves, true); totalApps.AddRange(NANDSystemTitleView.FS.Applications, true); totalTitles.AddRange(NANDSystemTitleView.FS.Titles, true); } if (NANDUserTitleView.FS != null) { totalSaves.AddRange(NANDUserTitleView.FS.Saves, true); lock (totalApps) // ensure threads don't try to modify list while iterating through it { foreach (KeyValuePair <ulong, Application> kv in NANDUserTitleView.FS.Applications) { ulong titleid = kv.Key; Application app = kv.Value; if (totalApps.ContainsKey(titleid)) { if (app.Main != null) { totalApps[titleid].AddTitle(app.Main); } if (app.Patch != null) { totalApps[titleid].AddTitle(app.Patch); } foreach (Title title in totalApps[titleid].AddOnContent) { if (title != null) { totalApps[titleid].AddTitle(title); } } } else { totalApps[titleid] = app; } } totalTitles.AddRange(NANDUserTitleView.FS.Titles, true); } } Applications.Clear(); Titles.Clear(); Saves.Clear(); Applications.AddRange(totalApps, true); Titles.AddRange(totalTitles, true); Saves.AddRange(totalSaves, true); TitlesChanged?.Invoke(Applications, Titles, Saves); }))); }