user145610
user145610

Reputation: 3025

How to stop Azure Worker Role

We have 1-2 worker,which spins 5 threads, each thread read messages from Azure queue and do long processing, each processing may take around 1-2 hrs. We would like to implement logic to Stop particular thread at particular worker role. User will submit request to cancel particular processing. We are saving worker role and thread information in our azure table. But we are stuck in implementing to stop particular worker role's thread which is processing. can any one give some idea/design to stop particular thread in particular worker. Can we make use of cancellation token of thread to stop thread. Please help us in stopping worker role's thread.

Upvotes: 1

Views: 397

Answers (1)

Adam
Adam

Reputation: 16199

You will need a flag of some sort. So either a new queue which is monitored or a DB update.

Then have a new thread started in your worker role that monitors for these cancellation messages/flags, picks the right thread and stops it.

I wouldn't recommend doing anything within the thread that is processing because it would slow down your work, however if your thread has an OnStop method, you can use that to tidy up the thread before shutting it down.

Upvotes: 1

Related Questions