Executing a command line program from C# with Process.Start() is up to 10 times slower?

394 views Asked by At

When I use the command line to print a file on my Windows 10 machine it finishes very quickly (40 seconds).

I use this command line call:

AcroRd32.exe /t document1.pdf

With the C# program, the printing of the same file takes up to 8 minutes, even though I'm calling Adobe Reader with the exact same arguments.

var printProcess = Process.Start("AcroRd32.exe", "/T \"document1.pdf\"");

I also tried the following workaround which unfortunately also resulted in a slower performance.

System.Diagnostics.Process.Start("CMD.exe", "/C AcroRd32.exe /t document1.pdf");

I originally thought this might be an Adobe Reader issue, but the exact same thing happens when using Foxit Reader.

Is this a known bug or am I doing something completely wrong? Is there a workaround for this (calling it in a different way, so that it is not a child process maybe)?

By printing time I mean the time the software/driver takes to send the file to the printer.

I greatly appreciate your help!

1

There are 1 answers

1
VillageTech On

Try to play with process priority (PriorityClass property):

using (Process process = new Process())
{
    process.StartInfo.FileName = "AcroRd32.exe";
    process.StartInfo.Arguments = "/T \"document1.pdf\"";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = false;

    process.PriorityClass = ProcessPriorityClass.AboveNormal;

    process.Start();
}