示例#1
0
 private static void StartPageProcessingThread()
 {
     if (pageProcessThread == null)
     {
         pageProcessThread = new System.Threading.Timer(new System.Threading.TimerCallback((object context) =>
         {
             bool acquired = pageProcessSemaphore.WaitOne(TimeSpan.FromSeconds(0));
             if (acquired)
             {
                 try
                 {
                     PageRoleWorker worker = new PageRoleWorker();
                     worker.ProcessMessages();
                 }
                 catch (Exception) { }
                 finally
                 {
                     pageProcessSemaphore.Release();
                 }
             }
         }), HttpContext.Current, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5));
     }
 }
示例#2
0
        private static void StartMessageTask(CancellationToken token)
        {
            PageRoleWorker worker = new PageRoleWorker();

            Logging.Database.Write("worker-role-queue", "Message processing task has started and is listening for messages.");
            while (!token.IsCancellationRequested)
            {
                worker.ProcessMessages();
                Thread.Sleep(100);
            }
            Logging.Database.Write("worker-role-queue", "Message processing task has detected shutdown.");
        }