private void RetrieveAndProcessOrdersFromQueue(string url, IProgress <string> progress) { var retriever = new OrderRetriever(Properties.Settings.Default.InventoryQueueUrl, Properties.Settings.Default.AwsAccessKey, Properties.Settings.Default.AwsSecret, Amazon.RegionEndpoint.USWest1); var processor = new OrderProcessorScreenBasedApi(progress); processor.Login(url, Properties.Settings.Default.Username, Properties.Settings.Default.Password, null); while (true) { List <Order> list = retriever.RetrieveFromQueue(Properties.Settings.Default.OrderSize); if (list.Count == 0) { progress.Report(String.Format("[{0}] Queue is now empty - we can stop.", System.Threading.Thread.CurrentThread.ManagedThreadId)); break; } else { progress.Report(String.Format("[{0}] Retrieved {1} orders from queue.", System.Threading.Thread.CurrentThread.ManagedThreadId, list.Count)); } if (processor.ProcessOrders(list)) { //If we crash at any point, the items will become visible in the queue again for processing by another thread after the visibility timeout has been exceeded retriever.DeleteFromQueue(list); lock (_syncLock) { _totalProcessed += list.Count; } } else { progress.Report(String.Format("[{0}] An error occured processing the orders; they will be left in the queue and we will try again.", System.Threading.Thread.CurrentThread.ManagedThreadId)); } } processor.Logout(); }
private void Warmup(string url, IProgress <string> progress) { var processor = new OrderProcessorScreenBasedApi(progress); processor.Login(url, Properties.Settings.Default.Username, Properties.Settings.Default.Password, null); }