void bgw_Init_DoWork(object sender, DoWorkEventArgs e) { /* 如果参数中传入了字符串,说明加载完Sequence Names以后切换到字符串指定的Sequence */ string seq_name_to_display; if (e.Argument != null) seq_name_to_display = e.Argument.ToString(); else seq_name_to_display = ""; /* 清空列表,启动Busy进度条 */ bgw_Init.ReportProgress(1); /* 加载Sequence Names */ using (CDatabase db = new CDatabase()) { if (db.GetSequenceNames(out seq_names)) { bgw_Init.ReportProgress(100, seq_name_to_display); } else { bgw_Init.ReportProgress(0, db.LastError); } } }
/// <summary> /// 启动一个加载SequenceNames和生成CureSN的线程 /// </summary> /// <param name="param"></param> public void LoadParameters() { string[] seq_names = null; string cure_sn = string.Empty; new Thread(() => { using (CDatabase db = new CDatabase()) { // 从数据库获取温度预设曲线名称列表 if (!db.GetSequenceNames(out seq_names)) { // 如果错误,通知View弹出错误对话框 Messenger.Default.Send<GenericMessage<string>>(new GenericMessage<string>(db.LastError), "DBError"); return; } else { this.SequenceNames = seq_names; RaisePropertyChanged("SequenceNames"); } if (!db.GetNewCureSN(ref cure_sn)) { // 如果错误,通知View弹出错误对话框 Messenger.Default.Send<GenericMessage<string>>(new GenericMessage<string>(db.LastError), "DBError"); } else { this.CureSN = cure_sn; RaisePropertyChanged("CureSN"); return; } } }).Start(); this.SelectedSeqName = null; this.Sequence = null; this.PatientName = ""; this.Result = false; }