Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • December 09, 2016, 07:32:39 AM
  • Proudly celebrating 10 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 2598 times)

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 245
    • View Profile
    • Mediaguy
    • Donate to Member
Q1 [Answered] Making a process and then changing its priority
« on: October 31, 2008, 03:06:48 PM »
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:10 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:44 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: 245
    • View Profile
    • Mediaguy
    • Donate to Member
Re: Making a process and then changing its priority
« Reply #2 on: October 31, 2008, 04:35:48 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