GetProcessesByName takes 10-15 seconds?

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Hi all,

Just started having a problem with this. It seems now that
GetProcessesByName will block for about 10-15 seconds before returning.
It never happened before, this is a recent development.

I'm NOT trying to prevent another instance of my program from starting,
so those solutions aren't applicable to my problem.

I've also read that some people claim the call causes access to the
floppy drive; I don't believe thats my problem here as I'm on a laptop
without a floppy drive.

Any ideas?

Thanks
Andy
 
Andy,

I think that the reason this occurs is because of the fact that it
creates internal structures for all the processes on the machine, which can
take some time.

Not the most efficient way to do it, IMO. What are you trying to do?
Perhaps there is a workaround.

Hope this helps.
 
GetProcessesByName works by getting it's information from a
PerformanceCounter. If the performance counter has become corrupt then that
could be causing your problem.
 
Andy said:
Hi all,

Just started having a problem with this. It seems now that
GetProcessesByName will block for about 10-15 seconds before returning.
It never happened before, this is a recent development.

I'm NOT trying to prevent another instance of my program from starting,
so those solutions aren't applicable to my problem.

I've also read that some people claim the call causes access to the
floppy drive; I don't believe thats my problem here as I'm on a laptop
without a floppy drive.

Any ideas?

Thanks
Andy

Better use System.Management classes for this.

using System.Management;

static void GetProcess(string Id)
{
SelectQuery query = new SelectQuery("SELECT * FROM win32_process where
Name ='" + Id +"'");
using(ManagementObjectSearcher searcher = new
ManagementObjectSearcher(query))
{
foreach(ManagementObject proc in searcher.Get())
{
foreach(PropertyData pd in proc.Properties)
Console.WriteLine("Property: {0}, Value: [{1}]",pd.Name,
pd.Value);
}
}
}

.....
GetProcess("explorer.exe");

Willy.
 
Hmm.. it didn't take this long before, and I have roughly the same
number of processes running.

I'm trying to make sure that a certain windows application (Filemaker)
is open. Unfortunatly, to use ODBC with FM 6, you need to talk to a
filemaker client, which will talk to the server on your behalf.

I need to know if its running or not, so that i can attempt to start it
if it is not.

Thanks
Andy
 
Back
Top