private void richTextBox_TextChanged(object sender, EventArgs e) { if (bw_status == BwStatus.READY) { try { bw_status = BwStatus.BUSY; this.richTextBox.SaveFile(StringConstants.TEMP_ABC, RichTextBoxStreamType.PlainText); this.update(); } catch (System.IO.IOException) { bw_status = BwStatus.PENDING; } finally { bw.RunWorkerAsync(); } } else if (bw_status == BwStatus.BUSY) { bw_status = BwStatus.PENDING; } }
public EditMotifForm(Motif m, Controller controller) { this.controller = controller; AbcFileWriter.saveToFile(m, StringConstants.TEMP_ABC, false); InitializeComponent(); this.update(); this.richTextBox.LoadFile(StringConstants.TEMP_ABC, RichTextBoxStreamType.PlainText); this.richTextBox.TextChanged += new System.EventHandler(this.richTextBox_TextChanged); bw = new BackgroundWorker(); bw.WorkerReportsProgress = true; bw.WorkerSupportsCancellation = true; bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); bw_status = BwStatus.READY; }