If you are developing something that requires use of 3rd party programs, it usually is a good idea to change the priority of the process to something below normal otherwise it may take up all server resources which could result in performance issues to other users.
The process priority can only be set through System.Diagnostics.Process:
System.Diagnostics.Process myProcess = null;
myProcess = System.Diagnostics.Process.Start(@"C:\\path\\to\\some\\program", "-param1 value1 -param2 value2...");
myProcess.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
However, if the process that is being started is an assembly such as Microsoft.Office.Interop.Word where you would use Word.Application oWord = new Word.Application(), setting the priority class is a little more difficult.
In my research, I was not able to find an easy way of setting the process to below normal, so I had to settle with a work around.
System.Diagnostics.Process[] thisProc = System.Diagnostics.Process.GetProcessesByName("WINWORD");
foreach (System.Diagnostics.Process proc in thisProc)
{
proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
}
This probably needs to be run with elevated privileges, so the full code would be:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
System.Diagnostics.Process[] thisProc = System.Diagnostics.Process.GetProcessesByName("WINWORD");
foreach (System.Diagnostics.Process proc in thisProc)
{
proc.PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
}
});