Example #1
0
        private static void WorkerDoWork(object sender, DoWorkEventArgs e)
        {
            var worker     = (BackgroundWorker)sender;
            var arg        = (FetchArg)e.Argument;
            var lastsecond = DateTime.Now.Second;
            var lastminute = -1;
            var lasthour   = -1;

            while (!worker.CancellationPending)
            {
                Thread.Sleep(400); // разрузка процессоров
                try
                {
                    var dt = DateTime.Now;
                    if (lastsecond == dt.Second)
                    {
                        continue;
                    }
                    lastsecond = dt.Second;
                    Data.FetchRisers(worker, arg);
                    if (lastminute == dt.Minute)
                    {
                        continue;
                    }
                    lastminute = dt.Minute;
                    if (lasthour == dt.Hour || dt.Minute != 0)
                    {
                        continue;
                    }
                    lasthour = dt.Hour;
                }
                catch (Exception ex)
                {
                    var mess = ex.FullMessage();
                    Console.WriteLine(mess);
                    Data.SendToErrorsLog("Ошибка в цикле опроса канала: " + mess);
                }
            }
        }