This project is read-only.

locking task scheduler

Jun 23, 2011 at 4:53 PM
Edited Jun 23, 2011 at 5:00 PM

The library is very nice and simple. 

Still I have a question : how can we make sure the task has finished before launching the next one ?

EDIT : just to clarify. I've noticed your disclaimer, with the reference to quartz.net for concurrency control and load balancing. My question is more : how would you do if you were to implement this ? I'm actually looking for a lightweight implementation on azure worker roles. Not to say that I want to reinvent the wheel, but quartz doesn't seem like the easiest for that matter. 

Jun 24, 2011 at 3:05 PM

The task would have to implement it. As mentioned in the docs:

In ScheduleDefinition, a ConditionsMet event is raised on its own thread via the OnConditionsMetAsync method (as called by the Evaluate method). Each of the ITasks that are connected to the ConditionsMet event will be executed in series on the worker thread.
In other words, when the current time matches the scheduled time, a new thread will be created to execute all of the attached ITasks, one after the other.
For a given ScheduleDefinition, each associated ITask will have one instance.

Because there is only one ITask per ScheduleDefinition, you can control concurrency within that object. Just new up a ReaderWriterLockSlim in Initialize and handle locking within HandleConditionsMet. If you need global locking, you'll need to use a static variable. Keep in mind that the ITasks for a given Schedule execute serially on a thread, so if you have multiple ITasks on that Schedule and one blocks, it may delay other tasks. 

Hope this is helpful.

Jun 30, 2011 at 8:41 AM

Thanks for your help, I will test that.

Jul 1, 2011 at 3:34 PM

Cool. If you want to contribute a base locking task, that would be great. Just fork the project and submit a pull request when done.

Jul 1, 2011 at 4:17 PM

sure, I'll keep you posted.