I have created a new winforms application. I am attempting to Create a class that listens to a storage queue for messages.
using System;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Queue;
using System.Threading;
using Microsoft.WindowsAzure.ServiceRuntime;
using System.Configuration;
namespace PMonitor
{
public class QueueWorker : RoleEntryPoint
{
public override void Run()
{
CloudQueue queue = clnt.GetQueueReference("stuff");
while (true)
{
CloudQueueMessage qMessage = null;
do
{
qMessage = queue.GetMessage(TimeSpan.FromSeconds(10));
if (qMessage != null)
{
//handle message
}
}
while (qMessage != null);
Thread.Sleep(10000);
}
}
public override bool OnStart()
{
return base.OnStart();
}
}
}
How do I engage the worker to start running in the Form to run and tell me when it finds a message in the queue?
Currently instantiating this class and calling Run() in the Form Load locks up the form.
What is the pattern for doing this?