AdvancedLauncher.UI.Pages.Gallery.UpdateThumbs C# (CSharp) Method

UpdateThumbs() private method

private UpdateThumbs ( string gamePath ) : void
gamePath string
return void
        private void UpdateThumbs(string gamePath)
        {
            BackgroundWorker bw = new BackgroundWorker();
            GalleryModel.UnLoadData();
            IsLoading(true);

            bw.DoWork += (s, e) => {
                string[] fileList = Directory.GetFiles(gamePath + SCREENSHOTS_DIR, "*.jpg");
                if (!Directory.Exists(gamePath + THUMBS_DIR)) {
                    try {
                        Directory.CreateDirectory(gamePath + THUMBS_DIR);
                    } catch {
                        return;
                    }
                }

                for (int i = 0; i < fileList.Length; i++) {
                    BitmapImage bitmap;
                    string thumbPath = gamePath + THUMBS_DIR + "\\" + Path.GetFileName(fileList[i]);
                    if (!File.Exists(thumbPath)) {
                        ImageEncoder.ResizeScreenShot(fileList[i], thumbPath);
                    }

                    if (File.Exists(thumbPath)) {
                        bitmap = ReadBitmapFromFile(thumbPath);
                    } else {
                        bitmap = ReadBitmapFromFile(fileList[i]);
                    }

                    DateTime result;
                    try {
                        result = DateTime.ParseExact(Path.GetFileNameWithoutExtension(fileList[i]), "yyMMdd_HHmmss", CultureInfo.InvariantCulture);
                    } catch (FormatException) {
                        result = File.GetCreationTime(fileList[i]);
                    }
                    this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new DoAddThumb((bitmap_, path_, date_) => {
                        GalleryModel.Add(new GalleryItemViewModel() {
                            Thumb = bitmap_,
                            FullPath = path_,
                            Date = date_
                        });
                    }), bitmap, fileList[i], result.ToString());
                }
            };
            bw.RunWorkerCompleted += (s, e) => {
                IsGalleryInitialized = true;
                IsLoading(false);
            };
            bw.RunWorkerAsync();
        }