public override void Run() { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); datatable = tableClient.GetTableReference("datatable"); datatable.CreateIfNotExists(); CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); urlQueue = queueClient.GetQueueReference("urlqueue"); urlQueue.CreateIfNotExists(); adminQueue = queueClient.GetQueueReference("adminqueue"); adminQueue.CreateIfNotExists(); ramCounter = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes"); cpuCounter = new System.Diagnostics.PerformanceCounter(); cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; crawler = new Crawler(); while (true) { Thread.Sleep(50); //If there is something in the admin queue if (adminQueue.PeekMessage() != null) { CloudQueueMessage message = adminQueue.GetMessage(); crawler.handleAdminMessage(message); adminQueue.DeleteMessage(message); } if (urlQueue.PeekMessage() != null) { crawler.crawlingPhase(urlQueue.GetMessage()); } } }