private void Execute(BackgroundWorker worker, DoWorkEventArgs args) { if (Thread.CurrentThread.Name == null) { Thread.CurrentThread.Name = "ParserUI"; } try { ParsingUiBackgroundWorkerArgument arg = args.Argument as ParsingUiBackgroundWorkerArgument; if (!string.IsNullOrEmpty(arg.Path) && Directory.Exists(arg.Path)) { if (arg.TagsOnly) { _arzParser.LoadArcTags(arg.Path, arg.ExpansionOnlyMod); } else { _arzParser.LoadArzDb(arg.Path, arg.LocalizationFile, arg.ExpansionOnlyMod); if (!arg.ExpansionOnlyMod && Directory.Exists(Path.Combine(arg.Path, "gdx1"))) { _arzParser.LoadArzDb(Path.Combine(arg.Path, "gdx1"), arg.LocalizationFile, true); } } } else { Logger.Warn("Could not find the Grim Dawn install location"); } } catch (UnauthorizedAccessException ex) { Logger.Warn(ex.Message); Logger.Warn(ex.StackTrace); Logger.Warn("Access denied trying to read a file. This may happen if Grim Dawn is currently running."); MessageBox.Show(string.Format("Access denied while parsing Grim Dawn\n\nEnsure that Grim Dawn is not currently running.", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (IOException ex) { MessageBox.Show($"{ex.Message}\n\nPerhaps Grim Dawn is running?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { Logger.Warn(ex.Message); Logger.Warn(ex.StackTrace); ExceptionReporter.ReportException(ex); throw; } }
public ParsingUiBackgroundWorker(RunWorkerCompletedEventHandler completed, ParsingUiBackgroundWorkerArgument args, ArzParser parser) { _arzParser = parser; _bw = new BasicBackgroundWorker(Execute, completed, args); }