2 using System.Collections.Generic;
\r
4 using System.Diagnostics;
\r
6 namespace Handbrake.CLI
\r
9 /// Delegate to handle pointers to event subscriptions regarding CLI jobs
\r
11 /// <param name="Sender">The object which raised the event using this delegate</param>
\r
12 /// <param name="Job">The job which caused this delegate to fire</param>
\r
13 public delegate void JobStatusHandler(Jobs.Job Job);
\r
16 /// still workin on this
\r
20 private static Queue<Process> m_processQueue = new Queue<Process>();
\r
23 /// Raised upon a job being completed
\r
25 public static event JobStatusHandler OnJobCompleted;
\r
28 /// Raised upon a new job starting
\r
30 public static event JobStatusHandler OnJobStarted;
\r
33 /// Raised upon any noteable progress during a job
\r
35 public static event JobStatusHandler OnJobProgress;
\r
38 /// Used for queueing up a job to be processed later
\r
40 /// <param name="job">The job to be processed later</param>
\r
41 public static void EnqueueJob(Jobs.Job job)
\r
43 //TODO: create new Process object from passed
\r
44 m_processQueue.Enqueue(CreateProcess(job));
\r
48 /// Starts the job queue
\r
50 public static void StartJobs()
\r
52 while (m_processQueue.Count > 0)
\r
54 Process proc = m_processQueue.Dequeue();
\r
61 /// Creates a new Process object from a Job object
\r
63 /// <param name="job">The Job object to create a process from</param>
\r
64 /// <returns>A Process object based on the requirements of the Job passed</returns>
\r
65 private static Process CreateProcess(Jobs.Job job)
\r
67 Process hbProc = new Process();
\r
68 hbProc.StartInfo.FileName = "hbcli.exe";
\r
69 hbProc.StartInfo.Arguments = job.ToString();
\r
70 hbProc.StartInfo.RedirectStandardOutput = true;
\r
71 hbProc.StartInfo.RedirectStandardError = true;
\r
72 hbProc.StartInfo.UseShellExecute = false;
\r
73 hbProc.StartInfo.CreateNoWindow = true;
\r
75 // Set the process Priority
\r
76 switch (Properties.Settings.Default.processPriority)
\r
79 hbProc.PriorityClass = ProcessPriorityClass.RealTime;
\r
82 hbProc.PriorityClass = ProcessPriorityClass.High;
\r
84 case "Above Normal":
\r
85 hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
\r
88 hbProc.PriorityClass = ProcessPriorityClass.Normal;
\r
91 hbProc.PriorityClass = ProcessPriorityClass.Idle;
\r
94 hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
\r