示例#1
0
        private void browseButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                foreach (string gamePath in openFileDialog.FileNames)
                {
                    // Check to see if it exists
                    if (_cache[gamePath] != null)
                    {
                        continue;
                    }

                    GameInformation game = this.LoadGameFromUmd(gamePath);
                    if (game != null)
                    {
                        _cache.Add(game);
                        umdGameListing.AddGame(game);

                        umdGameListing_SelectionChanged(umdGameListing, EventArgs.Empty);
                    }
                }

                _cache.Save();
            }
        }
示例#2
0
        private List <CharacterModel> LoadCharacterModels(bool unique)
        {
            if (_cache.TryLoadCache(out var cached))
            {
                var validCached = cached.Where(x => x.UniqueCharacter == unique).ToList();
                if (validCached.Any())
                {
                    return(validCached);
                }
            }
            else
            {
                cached = new List <CharacterModel>();
            }

            var files = Prefetch.Load().Files.Keys;

            var modelBag = new ConcurrentBag <CharacterModel>();

            var tasks = new ParallelTasks <string>(
                Environment.ProcessorCount, file =>
            {
                if (IsValid(file, unique))
                {
                    foreach (var model in GetCharacterModels(file))
                    {
                        modelBag.Add(model);
                    }
                }
            });

            tasks.Start();
            tasks.AddItems(files);
            tasks.WaitForComplete();

            GC.Collect();

            var modelList = modelBag.ToList();

            cached.AddRange(modelList);
            _cache.Save(cached);

            return(modelList);
        }