Book Image

Learning Microsoft Azure

By : Geoff Webber Cross, Geoff Webber-Cross
Book Image

Learning Microsoft Azure

By: Geoff Webber Cross, Geoff Webber-Cross

Overview of this book

Table of Contents (19 chapters)
Learning Microsoft Azure
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Completing the worker role


We now have all the tasks we need, so we can add them to the role:

using Microsoft.WindowsAzure.ServiceRuntime;
using OrderProcessorRole.Messaging;
using System;
using System.Diagnostics;
using System.Threading.Tasks;

namespace OrderProcessorRole
{
    public class WorkerRole : RoleEntryPoint
    {
        private OrderTopicProcessor _orderTopicProcessor = null;
        private BatchQueueProcessor _batchQueueProcessor = null;
        private StockQueueProcessor _stockQueueProcessor = null;
               
        public override void Run()
        {
            Trace.TraceInformation("OrderProcessorRole.WorkerRole.Run - Begin");

            try
            {
                // WaitAll tasks will block Run until they have all completed, otherwise the role will recycle itself
                Task.WaitAll(
                    Task.Run(() => this._orderTopicProcessor.ProcessSubscriptionAsync()),
                    Task.Run(() => this._batchQueueProcessor.ProcessQueueAsync...