private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { try { string path; BackgroundWorker worker; string uri = e.Url.ToString(); if (uri.ToLowerInvariant().EndsWith(".lpx")) { e.Cancel = true; DCDriverLoader.UnloadDomains(true); path = Path.Combine(this._tempDir, "TempDriver" + _random.Next(0xf4240) + ".lpx"); worker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; worker.DoWork += delegate(object sender, DoWorkEventArgs e) { WebClient webClient = WebHelper.GetWebClient(); webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) { if (worker.IsBusy) { worker.ReportProgress(e.ProgressPercentage); } }; webClient.DownloadFileAsync(new Uri(uri), path); while (webClient.IsBusy) { if (worker.CancellationPending) { webClient.CancelAsync(); break; } Thread.Sleep(100); } }; using (WorkerForm form = new WorkerForm(worker, "Downloading...", true)) { if (form.ShowDialog() != DialogResult.OK) { return; } } if (!this.TryImportFile(path)) { e.Cancel = true; } } } catch (Exception exception) { e.Cancel = true; Program.ProcessException(exception); } }
private void btnTest_Click(object sender, EventArgs e) { BackgroundWorker worker2 = new BackgroundWorker { WorkerSupportsCancellation = true }; string arg = this.rbStringConstructor.Checked ? this.txtCxString.Text.Trim() : null; Repository testRepos = ((Repository)this._cxInfo).Clone(); this.UpdateRepository(testRepos); worker2.DoWork += delegate(object sender, DoWorkEventArgs e) { using (DomainIsolator isolator = this.GetDomainIsolatorForProber("EF Connection Tester", true)) { isolator.GetInstance <AssemblyProber>().Test(testRepos, arg); } }; using (WorkerForm form = new WorkerForm(worker2, "Testing...", true)) { if (form.ShowDialog() != DialogResult.OK) { return; } } MessageBox.Show("Successful", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
private void DownloadSamples(string uri, string libName) { string tempPath = Path.Combine(Path.GetTempPath(), @"LINQPad\TempSampleQueries" + _random.Next(0xf4240) + ".zip"); BackgroundWorker worker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; worker.DoWork += delegate(object sender, DoWorkEventArgs e) { string path = Path.GetDirectoryName(tempPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } WebClient webClient = WebHelper.GetWebClient(); webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) { if (worker.IsBusy) { worker.ReportProgress(e.ProgressPercentage); } }; webClient.DownloadFileAsync(new Uri(uri), tempPath); while (webClient.IsBusy) { if (worker.CancellationPending) { webClient.CancelAsync(); break; } Thread.Sleep(100); } }; using (WorkerForm form = new WorkerForm(worker, "Downloading...", true)) { if (form.ShowDialog() != DialogResult.OK) { return; } } try { if (string.IsNullOrEmpty(libName)) { try { libName = Path.GetFileNameWithoutExtension(new Uri(uri).Segments.Last <string>()); } catch { } } if (this.UnzipFile(tempPath, libName)) { MessageBox.Show("Samples successfully loaded.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception exception) { Log.Write(exception, "Unzip samples"); MessageBox.Show("Error while unpacking sample queries: " + exception.Message, "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
private void btnTest_Click(object sender, EventArgs e) { BackgroundWorker worker2 = new BackgroundWorker { WorkerSupportsCancellation = true }; string arg = this.rbStringConstructor.Checked ? this.txtCxString.Text.Trim() : null; Repository testRepos = ((Repository) this._cxInfo).Clone(); this.UpdateRepository(testRepos); worker2.DoWork += delegate (object sender, DoWorkEventArgs e) { using (DomainIsolator isolator = this.GetDomainIsolatorForProber("EF Connection Tester", true)) { isolator.GetInstance<AssemblyProber>().Test(testRepos, arg); } }; using (WorkerForm form = new WorkerForm(worker2, "Testing...", true)) { if (form.ShowDialog() != DialogResult.OK) { return; } } MessageBox.Show("Successful", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }