topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 9:18 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

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

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
    • View Profile
    • Mediaguy
    • Donate to Member
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: C# [Select]
  1. System.Diagnostics.Process proc = new System.Diagnostics.Process();
  2.             //Some rubbish but long code removed
  3.             proc.EnableRaisingEvents = false;
  4.             proc.StartInfo.FileName = ffmpegLocation;
  5.             proc.StartInfo.Arguments = arguement;
  6.             proc.StartInfo.UseShellExecute = false;
  7.             if (showEncodingEngine)
  8.             {
  9.                 proc.StartInfo.CreateNoWindow = false;
  10.             }
  11.             else
  12.             {
  13.                 proc.StartInfo.CreateNoWindow = true;
  14.             }
  15.             proc.StartInfo.RedirectStandardOutput = false;
  16.             proc.StartInfo.RedirectStandardInput = false;
  17.             proc.StartInfo.RedirectStandardError = false;
  18.             proc.Start();
  19.             proc.WaitForExit();
  20.             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, 04:12 AM by mediaguycouk »

Ehtyar

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,237
    • View Profile
    • Donate to Member
Re: Making a process and then changing its priority
« Reply #1 on: October 31, 2008, 03:19 PM »
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
    • View Profile
    • Mediaguy
    • Donate to Member
Re: Making a process and then changing its priority
« Reply #2 on: October 31, 2008, 04:35 PM »
Thanks for that. Really hard to get things like this exactly right without working code snippits

Code: C# [Select]
  1. System.Diagnostics.Process proc = new System.Diagnostics.Process();
  2. proc.Start();
  3. proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
  4. proc.WaitForExit();
  5. proc.Close();
Learning C# - Graham Robinson