示例#1
0
 private void FormProgressBar_Load(object sender, EventArgs e)
 {
     lblNbElementsSelectionnes.Text = nbElementSelectionnes.ToString();
     this.Text = "0 %";
     BGProgressBar.RunWorkerAsync();
 }
示例#2
0
        private void BGProgressBar_DoWork(object sender, DoWorkEventArgs e)
        {
            Thread demoThread, demoThread1, demoThread2;

            if (this.deletedSubject == "Doctorant")
            {
                for (int i = 0; i < listDoctorants.Count; i++)
                {
                    if (nbElementSelectionnes > 0)
                    {
                        Thread.Sleep(rand.Next(500, 2000));
                        demoThread  = new Thread(() => ThreadProcSafeNbDeletedElements((i + 1).ToString()));
                        demoThread1 = new Thread(() => ThreadProcSafeIdentifier(listDoctorants[i].NOMPRENOM));
                        demoThread2 = new Thread(() => ThreadProcSafeDeletedStudentCIN(listDoctorants[i].CIN));
                        ImageUtilities.getPhoto(pbDoctorant, listDoctorants[i].CIN);
                        demoThread.Start();
                        demoThread1.Start();
                        demoThread2.Start();
                        BLFicheInformation.delete(listDoctorants[i].CIN);
                        ImageUtilities.deletePhoto(listDoctorants[i].CIN);
                        BGProgressBar.ReportProgress((i + 1) * 100 / nbElementSelectionnes);
                    }
                }
            }
            else if (this.deletedSubject == "Inscription")
            {
                ImageUtilities.getPhoto(pbDoctorant, listInscriptions[0].CIN);
                demoThread2 = new Thread(() => ThreadProcSafeDeletedStudentCIN(listInscriptions[0].CIN));
                demoThread2.Start();
                for (int i = 0; i < listInscriptions.Count; i++)
                {
                    if (nbElementSelectionnes > 0)
                    {
                        Thread.Sleep(rand.Next(500, 2000));
                        demoThread  = new Thread(() => ThreadProcSafeNbDeletedElements((i + 1).ToString()));
                        demoThread1 = new Thread(() => ThreadProcSafeIdentifier(listInscriptions[i].ID));
                        demoThread.Start();
                        demoThread1.Start();
                        BLInscription.Delete(listInscriptions[i].ID);
                        BGProgressBar.ReportProgress((i + 1) * 100 / nbElementSelectionnes);
                    }
                }
            }
            else
            {
                ImageUtilities.getPhoto(pbDoctorant, listDiplomes[0].CIN);
                demoThread2 = new Thread(() => ThreadProcSafeDeletedStudentCIN(listDiplomes[0].CIN));
                demoThread2.Start();
                for (int i = 0; i < listDiplomes.Count; i++)
                {
                    if (nbElementSelectionnes > 0)
                    {
                        Thread.Sleep(rand.Next(500, 2000));
                        demoThread  = new Thread(() => ThreadProcSafeNbDeletedElements((i + 1).ToString()));
                        demoThread1 = new Thread(() => ThreadProcSafeIdentifier(listDiplomes[i].ID));
                        demoThread.Start();
                        demoThread1.Start();
                        BLDiplome.Delete(listDiplomes[i].ID);
                        BGProgressBar.ReportProgress((i + 1) * 100 / nbElementSelectionnes);
                    }
                }
            }

            MessageBox.Show("Suppression terminée", "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.deleted = true;
            this.Invoke((Action)(() => { this.Dispose(); }));
        }