GetProcessName() terribly slow

  • Thread starter Thread starter Michi Henning
  • Start date Start date
M

Michi Henning

Hi,

the following statement takes around 1 second (!) to execute on my machine:

string progName = Process.GetCurrentProcess().ProcessName;

Why is this so terribly slow? This is a major pain for me because
the program is invoked repeatedly as part of a build environment.
The upshot is that it takes 30 seconds what otherwise takes about
2 seconds :-(

Is there another way to get the name of the process that is faster?
All I'm really looking for is the equivalent of argv[0] in C/C++.

Thanks,

Michi.
 
try using:

AppDomain.CurrentDomain.FriendlyName;

This should return the same thing, with better performance.

Bennie Haelen
 
try using:

AppDomain.CurrentDomain.FriendlyName;

This should return the same thing, with better performance.

This one is fast and works fine. Thanks a lot for your help!

Cheers,

Michi.
 
Back
Top