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





PostPosted: Top

Visual C#.Net >> Process.GetCurrentProcess().ProcessName slow. How to use AppDomain.CurrentDomain.FriendlyName

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

DotNet389