Advice on running a background .exe task

Topics: General
Nov 11, 2011 at 2:18 PM

I'm looking for any advice people might have on running a Windows executable process in the background of Orchard.

The process needs to be triggered from an Orchard module (but any experience of doing this in any .NET context would be really helpful).

I'm looking at either running an IBackgroundTask or IScheduledTask to do the work of checking the database and then triggering the executable. It'll be a long-running process so really I want to fire it up in a separate thread and allow the Orchard thread to close. But then I still need to pick the reins back up when the process finishes (and capture output to determine success), and possibly fire up another one. Basically there's a queue of large data files that need processing one by one with a command line tool; encoding videos into different formats, at the moment I'm looking at VideoLan's x264.exe for this. So I also need to limit the amount of CPU time the process uses (and perhaps limit it to a single CPU ... I of course have full admin rights on the server so full trust is not an issue),

I've got some ideas about how to try to set this up, but there are probably multiple ways I could tackle this and I'm a little unsure how best to proceed. I'm just wondering if anyone has any suggestions or advice for this scenario?

Nov 11, 2011 at 5:41 PM

You'd better have a scheduled task on windows to run a specific task.

Nov 11, 2011 at 6:24 PM
sebastienros wrote:

You'd better have a scheduled task on windows to run a specific task.

Well that's one option - but I still need a way to configure the task from my Orchard module, and the task needs to communicate a result back to Orchard (I need to capture the console output and parse it). Finally, the task can't purely be scheduled, because it needs to start on-demand, i.e. when I create a media content item in Orchard.