private void DownloadButton_Click(object sender, EventArgs e) { DownloadButton.Enabled = false; ChangesTextBox.AppendText(Environment.NewLine); ChangesTextBox.AppendText("Downloading..." + Environment.NewLine); var downloadAction = new Action(() => { Parallel.ForEach(m_newDefinitions, definition => { var localPath = Path.Combine(NFEPaths.DefinitionsDirectory, definition.Name); NFEPaths.EnsureDirectoryExists(NFEPaths.DefinitionsDirectory); GitHubApi.DownloadFile(definition.DownloadUrl, localPath); UpdateUI(() => ChangesTextBox.AppendText(definition.Name + " done." + Environment.NewLine)); }); UpdateUI(() => { DialogResult = DialogResult.OK; }); }); downloadAction.BeginInvoke(null, null); }
private void DownloadButton_Click(object sender, EventArgs e) { DownloadButton.Enabled = false; ChangesTextBox.AppendText(Environment.NewLine); ChangesTextBox.AppendText("Downloading..." + Environment.NewLine); var downloadAction = new Action(() => { Parallel.ForEach(m_newPatches, patch => { var localPath = PatchManager.GetPatchFilePath(m_definition, patch.Name); var directory = PatchManager.GetPatchDirectoryPath(m_definition); Paths.EnsureDirectoryExists(directory); GitHubApi.DownloadFile(patch.DownloadUrl, localPath); this.UpdateUI(() => ChangesTextBox.AppendText(patch.Name + " done." + Environment.NewLine)); }); this.UpdateUI(() => { DialogResult = DialogResult.OK; }); }); downloadAction.BeginInvoke(null, null); }