Example #1
0
        private void backgroundWorker_lancerSequence(object o, DoWorkEventArgs e)
        {
            this.communicationSerie.envoyerDonnees(GenerateurDePaquet.eteindreTout());

            switch (this.modeSelectionne)
            {
                case CommunicationSerie.modes.JOUR:

                    while (true)
                    {
                        for (int i = 0; i < this.listeBox_listeDeValeursJour.Items.Count; i++)
                        {
                            this.backgroundWorker.ReportProgress(i);

                            if (this.backgroundWorker.CancellationPending)
                                return;

                            Thread.Sleep(1000);
                        }
                    }
                    break;

                case CommunicationSerie.modes.NUIT:
                    while (true)
                    {
                        for (int i = 0; i < this.listeBox_listeDeValeursNuit.Items.Count; i++)
                        {
                            this.backgroundWorker.ReportProgress(i);

                            if (this.backgroundWorker.CancellationPending)
                                return;

                            Thread.Sleep(1000);
                        }
                    }
                    break;

                case CommunicationSerie.modes.COMPLET:

                    int indice = 0;
                    while (true)
                    {
                        this.modeCourant = this.communicationSerie.obtenirMode();

                        if (this.modeCourant == CommunicationSerie.modes.JOUR)
                        {
                            if (indice >= this.listeBox_listeDeValeursJour.Items.Count)
                            {
                                indice = 0;
                            }
                        }
                        else
                        {
                            if (indice >= this.listeBox_listeDeValeursNuit.Items.Count)
                            {
                                indice = 0;
                            }
                        }

                        this.backgroundWorker.ReportProgress(indice);

                        if (this.backgroundWorker.CancellationPending)
                            return;

                        Thread.Sleep(1000);
                        indice++;
                    }

                    



                    break;
            }
        }
Example #2
0
 private void clickSurBoutonDeLancement(CommunicationSerie.modes mode, Control control)
 {
     if (!this.estLance)
     {
         this.modeSelectionne = mode;
         this.verrouillerTousLesComposantsSauf(control);
         this.backgroundWorker.RunWorkerAsync();
         this.estLance = true;
     }
     else
     {
         this.backgroundWorker.CancelAsync();
     }
 }