Пример #1
0
        private void RunProcess(IProgress <List <string> > progress)
        {
            //init the queue
            var queue = new Queues(Properties.Settings.Default.AzureConnection, "testqueue");

            var updateList = new List <string>();
            var done       = false;
            var ctr        = 20;

            while (!done)
            {
                //check queue
                updateList.Add("Checking for queue");
                progress.Report(updateList);

                var queueObj = queue.GetNextMessage(TimeSpan.FromSeconds(20));

                //process if there was one found
                if (queueObj != null)
                {
                    updateList.Add("Queue item found: " + queueObj.AsString);
                    progress.Report(updateList);

                    updateList.Add("Process");
                    progress.Report(updateList);

                    updateList.Add("De-queue");
                    progress.Report(updateList);

                    queue.DeQueue(queueObj);

                    updateList.Add("Queue finished");
                    progress.Report(updateList);

                    done = true;
                }

                if (!done)
                {
                    Thread.Sleep(5000);
                    ctr--;
                    if (ctr == 0)
                    {
                        done = true;
                    }
                }
            }

            updateList.Add("done");
            progress.Report(updateList);
        }
Пример #2
0
        private void RunProcess(IProgress<List<string>> progress)
        {
            //init the queue
            var queue = new Queues(Properties.Settings.Default.AzureConnection, "testqueue");

            var updateList = new List<string>();
            var done = false;
            var ctr = 20;

            while (!done)
            {
                //check queue
                updateList.Add("Checking for queue");
                progress.Report(updateList);
                
                var queueObj = queue.GetNextMessage(TimeSpan.FromSeconds(20));
                
                //process if there was one found
                if (queueObj != null)
                {
                    updateList.Add("Queue item found: " + queueObj.AsString);
                    progress.Report(updateList);

                    updateList.Add("Process");
                    progress.Report(updateList);

                    updateList.Add("De-queue");
                    progress.Report(updateList);

                    queue.DeQueue(queueObj);
                    
                    updateList.Add("Queue finished");
                    progress.Report(updateList);

                    done = true;
                }

                if (!done)
                {
                    Thread.Sleep(5000);
                    ctr--;
                    if (ctr == 0)
                        done = true;
                }
            }

            updateList.Add("done");
            progress.Report(updateList);
        }