private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string[] args = (string[])e.Argument; try { BFInt bfi = new BFInt(args[0], args[1], setting, useExtentions); while (bfi.next()) { string res = bfi.getOutput(); if (res != "") { res = res.Replace("\0", "\u2400"); this.Invoke((MethodInvoker) delegate { txtOutput.Text += res; // runs on UI thread }); } if (worker.CancellationPending) { e.Cancel = true; break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void stripCommentsToolStripMenuItem_Click(object sender, EventArgs e) { BFInt bfi = new BFInt(txtProg.Text, "", setting, useExtentions); txtProg.Text = bfi.getProg(); }