Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my application startup time slower when I use Process.Start()?

Tags:

c#

app-startup

I'm trying to profile the startup time of my application, so I wrote a small C# program that will start my application using the Process.Start() method, and time it using a stopwatch.

When I try to start the application myself (by just clicking on it), it probably takes 2-3 seconds. When I try to start the application using my test program, it takes 8-10 seconds. The startup time consistently differs in that magnitude.

Any idea why using Process.Start to start an executable would affect startup times so much?

like image 720
dreadpirateryan Avatar asked Aug 27 '10 01:08

dreadpirateryan


1 Answers

Thanks for all your help. I have the answer, and it's unrelated to Process.Start.

After I start the process, I was waiting for a specific window handle to appear to know that the app actually showed up. The loop was too tight. I introduced a 200 ms sleep in the while loop, and startup time was normal again.

like image 54
dreadpirateryan Avatar answered Oct 01 '22 04:10

dreadpirateryan