c# - How to Schedule a task in windows azure worker role -
i have simple azure worker role running performs task every day @ 12 pm. below code accomplishes 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() method send email @ every day 12 pm, , fires once , once per day.
how can implement scheduler fire when time 12pm , execute dosomethingelse().
my question is: (above code) best method or use 3rd party tool.
there several other questions here deal (and i've marked 1 above). having said that, , @ risk of repeating other answers state:
in case, simple message on windows azure queue, time-delayed not show until noon, work. helps deal multi-instance scenarios: if you're running 2 instances of role, don't want same scheduled task running twice, need way have 1 of instances execute code. handled via queue message, or run scheduler code on single instance using blob lease (which may have 1 write-lock against it) mutex. covered in @smarx's blog post, here.
Comments
Post a Comment