private void BwSearch_DoWork(object sender, DoWorkEventArgs e) { var searchWhat = e.Argument as String; try { if (doMode == DoMode.Confirm) { osmConfirmList = OutsoleMaterialController.GetOSConfirmByIndexNo(int.Parse(searchWhat)); } else if (doMode == DoMode.Release) { osmConfirmList = OutsoleMaterialController.GetOSConfirmByPO(searchWhat); sizeRunList = SizeRunController.Select(searchWhat); } } catch (Exception ex) { Dispatcher.Invoke(new Action(() => { MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error); })); } }