public virtual async Task ImportGames(string emulatorPath, IEnumerable <GameInfo> gameInfos, Action <GameInfo, string> callback, Action deferredCallback) { var updateGameInfos = new Queue <Action>(); await gameInfos.ParallelForEachAsync(async gameInfo => { if (gameInfo.GameId != null) { return; } var(name, region, id) = await IdentifyGame(emulatorPath, gameInfo.Path); var newInfo = new GameInfo(gameInfo) { DisplayName = name, Region = region, GameId = id != "???" ? id : null }; var cover = await coverService.GetCoverForGame(newInfo); updateGameInfos.Enqueue(() => { gameLibraryService.UpdateGameInfo(newInfo.Name, newInfo, shouldReloadLibrary: true); remoteConfigService.ImportConfig(newInfo.GameId, emulatorPath); }); callback.Invoke(newInfo, cover); }, maxDegreeOfParallelism : 20); while (updateGameInfos.Count > 0) { updateGameInfos.Dequeue()?.Invoke(); } deferredCallback?.Invoke(); }
private async void SaveBindings() { foreach (var game in gameModels) { var gameInfo = gameLibraryService.Games.FirstOrDefault(x => x.DisplayName == game.Game); if (gameInfo != null) { gameLibraryService.UpdateGameInfo(gameInfo.Name, new GameInfo(gameInfo) { EmuVersion = game.Version, Config = game.Config, LaunchOptions = game.LaunchOptions }); } } await settings.UpdateUserSettings(); }