private void GenerateCookbook(object sender, RoutedEventArgs e) { MessageTextbox.Clear(); MessageTextbox.AppendText($"Generating cookbook version {ScottPlot.Tools.GetVersionString()}" + Environment.NewLine); BackgroundWorker worker = new BackgroundWorker(); worker.WorkerReportsProgress = true; worker.DoWork += CookbookWorker_DoWork; worker.ProgressChanged += CookbookWorker_ProgressChanged; worker.RunWorkerCompleted += CookbookWorker_RunWorkerCompleted;; worker.RunWorkerAsync(); }
private void CookbookWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { // you may access GUI components from this thread MessageTextbox.AppendText($"Cookbook generation complete!"); }
private void CookbookWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { Debug.WriteLine(e.UserState); MessageTextbox.AppendText(e.UserState.ToString() + Environment.NewLine); MessageTextbox.ScrollToEnd(); }