Exemplo n.º 1
0
        private static void StartImportSiteTask(CancellationToken token)
        {
            ImportSiteWorker worker = new ImportSiteWorker();

            Logging.Database.Write("worker-role-queue", "Import site processing task has started and is listening for messages.");
            while (!token.IsCancellationRequested)
            {
                worker.ProcessMessages();
                Thread.Sleep(100);
            }
            Logging.Database.Write("worker-role-queue", "Import site processing task has detected shutdown.");
        }
Exemplo n.º 2
0
 private static void StartSiteImportThread()
 {
     if (siteImportThread == null)
     {
         siteImportThread = new System.Threading.Timer(new System.Threading.TimerCallback((object context) =>
         {
             bool acquired = siteImportSemaphore.WaitOne(TimeSpan.FromSeconds(0));
             if (acquired)
             {
                 try
                 {
                     ImportSiteWorker worker = new ImportSiteWorker();
                     worker.ProcessMessages();
                 }
                 catch (Exception) { }
                 finally
                 {
                     siteImportSemaphore.Release();
                 }
             }
         }), HttpContext.Current, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));
     }
 }