I am looking for a design pattern to execute a list of jobs queued up in a table, asynchronously and also update the job status in the database (completed/failed/cancelled). preferably I should be able to kill a job as well on user demand just in case the job takes more time to execute than expected or if the user kicked off the job mistakenly. each of these jobs take a while to execute.
I can have a windows service which monitors the table for any new jobs and then use multi-threading to execute them asynchronously. but multi-threading is complex and error-prone. will using WCF services be helpful in anyway for this purpose? for example instead of multi-threading, can I have a WCF service to execute the jobs and call it asynchronously and then subscribe to its completed event to update the job status? which option is better or it doesn’t really matter? as I said I need to be able to cancel the job as well if required.
Look into the Task Parallel Library. It facilitates seemingly everything you need, with the only real complexity coming in where you need to feed the jobs to your factory, so to speak.
Apologies for such a short answer with no examples, I’m both on my phone and trying to eat.