Ejemplo n.º 1
0
 protected void InvokeStateChanged(int no, string msg)
 {
     if (OnStateChanged(no, msg))
     {
         StateChanged?.BeginInvoke(no, msg, null, null);
     }
 }
Ejemplo n.º 2
0
 static void service()
 {
     try
     {
         Log.Main.Inform("STATRED");
         actual_work = true;
         while (true)
         {
             if (actual_work)
             {
                 CrawlerService.Run();
                 manage_services();
             }
             if (actual_work != work)
             {
                 if (StateChanged != null)
                 {
                     StateChanged.BeginInvoke(work, null, null);
                 }
                 actual_work = work;
                 if (actual_work)
                 {
                     Log.Main.Write(Log.MessageType.INFORM, "STARTED");
                 }
                 else
                 {
                     Log.Main.Write(Log.MessageType.INFORM, "STOPPED");
                 }
             }
             ThreadRoutines.Wait(Properties.Settings.Default.PollIntervalInMss);
             //ThreadRoutines.WaitForCondition(() => { if (!work) return work; return null; }, Properties.Settings.Default.PollIntervalInSecs * 1000, 100);
         }
     }
     catch (Exception e)
     {
         Log.Main.Error(e);
         Mailer.Send(db, Log.GetExceptionMessage(e), ReportSourceType.MANAGER, Log.GetExceptionMessage(e));
     }
     if (StateChanged != null)
     {
         StateChanged.BeginInvoke(false, null, null);
     }
 }