private void btnThoat_Click(object sender, EventArgs e) { if (m_BackgroundWorker.IsBusy) { m_BackgroundWorker.CurrentThread.Suspend(); m_BackgroundWorker.StopImmediately(); } this.Close(); }
public void StopTask() { SanitaLogEx.e(TAG, "Stop task..."); try { if (m_BackgroundWorker.CurrentThread != null) { m_BackgroundWorker.CurrentThread.Suspend(); m_BackgroundWorker.StopImmediately(); } } catch (Exception ex) { SanitaLog.e(TAG, ex); } }
private void btnThoat_Click(object sender, EventArgs e) { if (mWorker == null) { return; } try { if (MessageBox.Show("Are you sure you want to stop this task ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { mWorker.CurrentThread.Suspend(); mWorker.StopImmediately(); this.Close(); } } catch (Exception ex) { //System.Windows.Forms.MessageBox.Toast(this, "Dừng tiến trình thất bại !"); } }