473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
Nov 16 '05 #1
0 4426

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ken Varn | last post by:
Everytime I call Process.GetCurrentProcess() the system goes out to the floppy drive. Why does this happen. I decided to use FileMon to get a log of what is happening when this occurs. Here is...
2
by: Jeffrey Palermo, MCAD.Net | last post by:
I have some classes that control file processing in c#. The files come from a mainframe and may take some time for each to process. I use the Threadpool to process multiple files at once. Each...
5
by: kd | last post by:
Hi All, If the name of a process is known, is it possible to check whether it is in execution? What I did was to fetch all the processes running on the system using Process.GetProcesses() and...
4
by: Andy | last post by:
Hi, I was wondering if it was possible to get the Entry assembly for the default application domain (and how to determine what the default app domain is..). I'd like to get to it for logging...
2
by: John | last post by:
I get this error while reading my config file but it is only occasionally and not all the time. I'm not sure why its happening. Does anyone know what could be going wrong? Thanks. The process...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
2
by: Tim | last post by:
Hey guys, I tried to get a process handle with the following code snippet: 00 Process processes = Process.GetProcesses(); 01 if (null != processes && processes.Length 0) 02 { 03 foreach...
1
by: Polaris | last post by:
Hi C# Experts: I have 2 threads and I like to run them in seperate AppDomains. In other words, I want to start 2 new AppDomains and then run a thread within each of the AppDomains. How to do...
0
by: PRR | last post by:
Here is a code i found on "how to enumerate appdomains in a current process". The original code was posted by Thomas Scheidegger Add the following as a COM reference -...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.