How to assign a task as the azure popup window

I have a simple Azure Worker role that performs a task every day at 12 o’clock. Below is the code that executes this.

public override void Run() { try { while (true) { int time = Convert.ToInt32(DateTime.Now.TimeOfDay); if (time == 12) { DoSomethingElse(); } } } catch (Exception ex) { Log.Add(ex, true); } } 

Here, DoSomethingElse() is a method of sending emails every day at 12pm, and also fires once and only once a day.

How can I implement a scheduler that fires when the time is 12PM and execute DoSomethingElse() .

My question is: Is this (above code) the best method or is it using any third-party tool.

+8
c # azure
source share
4 answers

There are several other issues here that relate to this (and I noted one above). Having said that and risking repeating what the other answers already say:

In your case, a simple message in the Windows Azure queue will work with a time delay so that it does not appear until noon. It also helps to cope with multi-instance scripts: if you use two instances of your role, you do not want the same scheduled task to be executed twice, so you need a way for only one of these instances to execute this code. This is easily handled through a queue message, or you can run the scheduler code in a single instance using something like a blob rental (which can only have write locks against it) as a mutex. This is described in the @smarx blog post here .

+5
source share

You can also use Quartz.Net http://quartznet.sourceforge.net/ using the blob rental mentioned ab ove is a great way to make sure that only one of your instances is performing tasks.

Using Quartz.Net to schedule tasks in Windows Azure workspace roles

+1
source share

Cloud Scheduler is specifically dedicated to scheduling tasks in the cloud.

I just stumbled upon this, so I have not tried.

http://getcloudscheduler.com/

Refresh . Forget the cloud planner! I carried out my daily schedule 600 times in a row, as a result of which 600 letters were sent to my clients. Do not use!!!

0
source share

Use the Azure Task Scheduler . A good Scott Gu tutorial is here .

In particular, I would look at the type of action "Storage Queue" - just register for queue events in your worker role.

(Note that this service can cost money if you want to schedule tasks more often than every hour.)

0
source share

All Articles