Concurrent task execution within Orchard Code for anyone who wants it

Topics: General
Apr 10, 2013 at 3:33 AM
There's not much around concurrent task execution in orchard - all the schedulers (and defaultprocessingengine) seem to run in single sequential queues - on exceptions this even stops the schedules from working! If you queue anything that lasts longer than a minute - your queue may never disappear (I found it also caused re-runs of older jobs using the the schedule... eek)

Running tasks from the new .net async library or using other threads not in the orchard context kills injections so you miss out on all the nifty orchard features....

There's ways to overcome this - and I've implemented a service similar to the scheduledtask service/handler but with concurrency supported:

https://github.com/Xstract/xodb/blob/master/src/main/XODB.Orchard/src/Orchard.Web/Modules/XODB/Services/ConcurrentTaskService.cs

It just takes a method with a contentitem and runs it asynchronously.

Hope it helps someone
Andrew