} // GetMessagesAsync private void GetDataCompleted(object sender, RunWorkerCompletedEventArgs e) { // The background process is complete. First we should hide the // modal Progress Form to unlock the UI. The we need to inspect our // response to see if an error occurred, a cancel was requested or // if we completed successfully. if (frmProgress != null) { frmProgress.Hide(); frmProgress = null; } // Check to see if an error occurred in the // background process. if (e.Error != null) { MessageBox.Show(e.Error.Message); return; } object[] fetchedCnts = (object[])e.Result; // Check to see if the background process was canceled. if (e.Cancelled) { MessageBox.Show(String.Format("操作取消!共更新 {0} 个订单,{1} 个消息", (int)fetchedCnts[0], (int)fetchedCnts[1]), "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); this.buttonSyncEbayData.Enabled = true; asyncWorder = null; return; } // Everything completed normally. // process the response using e.Result MessageBox.Show(String.Format("恭喜!下载ebay订单完成,共更新 {0} 个订单, 下载 {1} 个新消息 .", (int)fetchedCnts[0], (int)fetchedCnts[1]), "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); this.buttonSyncEbayData.Enabled = true; asyncWorder = null; LoadData(); isSyncingData = false; }
} // SendMessageAsync private void SendMessageCompleted(object sender, RunWorkerCompletedEventArgs e) { if (frmProgress != null) { frmProgress.Hide(); frmProgress = null; } // Check to see if an error occurred in the // background process. if (e.Error != null) { MessageBox.Show(e.Error.Message); return; } int sentMessageCnt = (int)e.Result; // Check to see if the background process was canceled. if (e.Cancelled) { MessageBox.Show(String.Format("操作取消!共发送 {0} 个消息", sentMessageCnt), "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); this.buttonSendMessage.Enabled = true; asyncWorder = null; return; } // Everything completed normally. // process the response using e.Result MessageBox.Show(String.Format("恭喜!发送消息成功,共发送 {0} 个消息 .", sentMessageCnt), "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); this.buttonSendMessage.Enabled = true; asyncWorder = null; isSendingMessage = false; MessageSent = true; } // SendMessageCompleted