Process.GetCurrentProcess().ProcessName slow. How to use AppDomain.CurrentDomain.FriendlyName

  • Thread starter Thread starter GrantS
  • Start date Start date
G

GrantS

To ensure my C# Winforms application can only have one instance
running, I am using the code below:

string proc=Process.GetCurrentProcess().ProcessName;
// get the list of all processes by that name
Process[] processes=Process.GetProcessesByName(dname);

The 'getting of the current process' [first line of code] takes 10
seconds. This is too slow. Apparently the
AppDomain.CurrentDomain.FriendlyName can be used for this and it runs
much faster. How do I use AppDomain.CurrentDomain.FriendlyName in this
instance?

Thanks

Grant
 
Back
Top