コード例 #1
0
        public void Executar(object _form1)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            List <Link> lista            = GerenciadorLinks.LerLinks();
            double      TotalLinks       = lista.Count();
            double      LinkProcessAtual = 0;

            Painel.model.QuantidadeErros = 0;
            if (this.InvokeRequired)
            {
                Invoke(new Action(() => {
                    progressBar1.Visible = true;
                }));
            }

            foreach (var link in lista)
            {
                GerenciadorAcesso.AcessarLink(link.Endereco);
                LinkProcessAtual++;

                double porcentagem = LinkProcessAtual / TotalLinks * 100;
                if (this.InvokeRequired)
                {
                    //Thread.Sleep(5000);
                    Invoke(new Action(() => {
                        progressBar1.Value = Convert.ToInt32(porcentagem);
                    }));
                }
            }
            sw.Stop();

            Painel.model.TempoDecorrido = sw.Elapsed;
            Painel.model.UltimaExecucao = DateTime.Now;

            if (_painel.InvokeRequired)
            {
                Invoke(new Action(() => {
                    _painel.AtualizarTextoTela();
                }));
            }

            ((Form1)_form1).notifyIcon1.ShowBalloonTip(1000, "Certweb", "Tarefa executada com sucesso!", ToolTipIcon.Info);

            //MessageBox.Show("Sucesso!");
        }