private void pictureCancel_Click(object sender, EventArgs e) { try { if (!bgw.CancellationPending) { try { status = true; bgw.CancelAsync(); this.Visible = false; this.Close(); //System.Diagnostics.Process.Start(Application.StartupPath + @"/Kiosk_eBrochure_M.exe"); //System.Environment.Exit(0); frmSearchMobile f = new frmSearchMobile(); f.ShowDialog(); } catch (Exception ex) { } } } catch (Exception ex) { } }
void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (status == true) { return; } try { //System.Threading.Thread.Sleep(10000); if (frCompare.ImageFileName != null) { //do the code when bgv completes its work // this.Close(); this.Visible = false; this.Close(); frmCameraResult Detect = new frmCameraResult(); Detect.StartPosition = FormStartPosition.CenterScreen; Detect.ShowImage(frCompare); Detect.ShowDialog(); // MessageBox.Show(Similarities * 100 + ""); } else { lblPercent.Text = "ไม่พบข้อมูล"; pictureClose2.Visible = true; this.Visible = false; this.Close(); frmSearchMobile f = new frmSearchMobile(); f.ShowDialog(); //needClose = false; //PopulateData(); } //lblPercent.Text = "ไม่พบข้อมูล"; } catch (Exception exRunWorkerCompleted) { } }