コード例 #1
0
ファイル: WorkerRole.cs プロジェクト: beachead/gooey-cms-v2
        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.");
        }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: beachead/gooey-cms-v2
 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));
     }
 }