private void initializeBackgroundWorker() { bg36 = new BackgroundWorker(); bg36.DoWork += bg36_DoWork; bg36.RunWorkerCompleted += bg36_RunWorkerCompleted; bg36.WorkerReportsProgress = true; bg36.ProgressChanged += bg36_ProgressChanged; bg36.WorkerSupportsCancellation = true; }This is how the process is started:
private void bg36_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bw = (BackgroundWorker)sender;This is the call to the UI thread
bw.ReportProgress(0, "save ledgers");And this is the routine I would like to complete before the worker continues
private void bg36_ProgressChanged(object sender, ProgressChangedEventArgs e) { statusTextBlock.Text = (string)e.UserState + "\n\n" + Monitor.peek(); if ((string)e.UserState== "save ledgers") { saveLedgers(); } }