DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Q1 [Answered] Making a process and then changing its priority  (Read 5,949 times)

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
Hi there. I'm back to C# and am getting by with web examples and a few books. However I'm stuck.

I've created a process and it happens to be FFMPEG

Code: (csharp)
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            //Some rubbish but long code removed
            proc.EnableRaisingEvents = false;
            proc.StartInfo.FileName = ffmpegLocation;
            proc.StartInfo.Arguments = arguement;
            proc.StartInfo.UseShellExecute = false;
            if (showEncodingEngine)
            {
                proc.StartInfo.CreateNoWindow = false;
            }
            else
            {
                proc.StartInfo.CreateNoWindow = true;
            }
            proc.StartInfo.RedirectStandardOutput = false;
            proc.StartInfo.RedirectStandardInput = false;
            proc.StartInfo.RedirectStandardError = false;
            proc.Start();
            proc.WaitForExit();
            proc.Close();

What I'd like to do is to have this process run in BelowNormal processor priority. I've found some things in the intelitext about it, but msdn isn't really helping me.

Psudo code would be

proc.Start();
proc.processorpriority = priority.BelowNormal;

But it isn't that easy...

Thanks for any help
Learning C# - Graham Robinson
« Last Edit: November 02, 2008, 10:12 AM by mediaguycouk »

Ehtyar

  • That News Guy
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,237
    • Plugin Coding Medal
    • Gathering Badge
Re: Making a process and then changing its priority
« Reply #1 on: October 31, 2008, 08:19 PM »
Code
proc.PriorityClass = ProcessPriorityClass.BelowNormal;
Documentation for PriorityClass class here and documentation for the ProcessPriorityClass enum here.

Hope this helps, Ehtyar.

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
Re: Making a process and then changing its priority
« Reply #2 on: October 31, 2008, 09:35 PM »
Thanks for that. Really hard to get things like this exactly right without working code snippits

Code: (csharp)
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.Start();
proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
proc.WaitForExit();
proc.Close();
Learning C# - Graham Robinson

Original address: https://www.donationcoder.com/forum/index.php?topic=15549.0