void _ThreadClass_ProgressFinished(object sender, ProcessThread.ProgressArgs e) { if (this.Dispatcher.CheckAccess()) { //Set progress bar color. switch (e.Status) { case ItemProgress.ProcessStatusEnum.Error: this.barProgress.Foreground = new SolidColorBrush(Colors.Red); break; case ItemProgress.ProcessStatusEnum.Processing: this.barProgress.Foreground = new SolidColorBrush(Colors.Yellow); break; } if (this.barProgress.IsIndeterminate) { this.barProgress.IsIndeterminate = false; } for (int i = 0; i < procedureCompleteDelegates.Count; i++) { procedureCompleteDelegates[i].Invoke(); } } else { _ThreadClass_ProgressFinishedCallback callB = new _ThreadClass_ProgressFinishedCallback(this._ThreadClass_ProgressFinished); this.Dispatcher.Invoke(callB, new object[] { sender, e }); } }
/// <summary>Hit in the other thread when an update is requested.</summary> /// <param name="sender">ThreadClass</param> /// <param name="e">ProcessThread.ProgressArgs</param> private void _ThreadClass_ProgressUpdate(object sender, ProcessThread.ProgressArgs e) { if (this.Dispatcher.CheckAccess()) { //Update form! // - Progress bar. if (e.Progress > -2) { this.barProgress.IsIndeterminate = (e.Progress == -1); this.barProgress.Value = ((e.Progress == -1) ? 0 : e.Progress); } // - Task item. ItemProgress selectItem = (ItemProgress)this.itemsToDo.Children[e.TaskNum]; selectItem.SetActionStatus = e.Status; selectItem.SetErrorString = e.ErrorText; } else { _ThreadClass_ProgressUpdate_Callback callB = new _ThreadClass_ProgressUpdate_Callback(this._ThreadClass_ProgressUpdate); this.Dispatcher.Invoke(callB, new object[] { sender, e }); } }