GetProcesses hangs on XP

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

Tomas,

Getting the process information can take a while. It's most likely that
it is not hanging, but just you have a lot of processes running on your
machine.

How many processes do you see in task manager when it comes up? Have
you let it run, and attempted to let it finish?
 
Hello All,
I'ma having trouble getting GetCurrentProcess() to work properly.
What I'm trying to accomplish is list all running processes. But my
call get GetProcesses() hangs.

While testing things out I found that the tiny program listed below
hangs as well.

Am I missing something?

-tomas


//---- This app hangs ----
using System;
using System.Diagnostics;

namespace proctest
{

class Class1
{

[STAThread]
static void Main(string[] args)
{

Console.WriteLine(Process.GetCurrentProcess().ProcessName);
}
}
}

// -- What's wrong with this code?
 
Nicholas,
Thanks for your reply.

There are about 60 processes running.
I've let the app wait for about 4 minutes. Is this typical?

Thanks for your help.

-tomas
 
Tomas,

That is a good number of processes. What information are you trying to
retreive from the processes? It might be better to use WMI instead.
 
Tomas Vera said:
Hello All,
I'ma having trouble getting GetCurrentProcess() to work properly.
What I'm trying to accomplish is list all running processes. But my
call get GetProcesses() hangs.

While testing things out I found that the tiny program listed below
hangs as well.

Am I missing something?

-tomas


//---- This app hangs ----
using System;
using System.Diagnostics;

namespace proctest
{

class Class1
{

[STAThread]
static void Main(string[] args)
{

Console.WriteLine(Process.GetCurrentProcess().ProcessName);
}
}
}

// -- What's wrong with this code?

This tiny program should return within seconds. What version of XP (SP) and
..NET are you running?
Are you running this as domain user or as a local user, how many user tokens
do you have in you account group?

Willy.
 
Nicholas,

Eventually, I need to be able to detect and use existing instances of
MS Excel and Word for some applications that I'm developing. But I've
only been playing with processes for about 2 days.

So in the short term, I'm simply trying to get the process names to
display them. I didn't expect that this should take as long as it
does.

I'll try it again this evening.

Thanks for your help.

-tomas
 
Willy,
I'm running in XP SP2 (.NET 1.1.4322)

I'm running as a local user on my laptop. Only 1 user on the machine.

One thing to note: if I use this code:

private void TestFunction()
{
Process proc;
proc = Process.GetCurrentProcess();
string procName = proc.ProcessName; <-- HANGS HERE
Console.WriteLine(procName);
}

The "proc =" assignment returns as expected. But if I try to examine
the properties of "proc" (in the debugger), "proc" it looks like an
uninitialized object.
Then the "procName=" line hangs (or appears to hang).

I still need to try elimintating all the unnecessary processes and
waiting longer, (as suggested by Nicholas) to see if that allows the
app to work.

But I don't understand why the "proc=" line return what appears to be
an improperly init'd object.

Thanks for your help.

-tomas

Tomas Vera said:
Hello All,
I'ma having trouble getting GetCurrentProcess() to work properly.
What I'm trying to accomplish is list all running processes. But my
call get GetProcesses() hangs.

While testing things out I found that the tiny program listed below
hangs as well.

Am I missing something?

-tomas


//---- This app hangs ----
using System;
using System.Diagnostics;

namespace proctest
{

class Class1
{

[STAThread]
static void Main(string[] args)
{

Console.WriteLine(Process.GetCurrentProcess().ProcessName);
}
}
}

// -- What's wrong with this code?

This tiny program should return within seconds. What version of XP (SP) and
.NET are you running?
Are you running this as domain user or as a local user, how many user tokens
do you have in you account group?

Willy.
 
Tomas,

How does this tiny program behaves when run from the commandline (in debug
or retail version).

Willy.
PS did you install SP1 for .NET 1.1.4322 ?


Tomas Vera said:
Willy,
I'm running in XP SP2 (.NET 1.1.4322)

I'm running as a local user on my laptop. Only 1 user on the machine.

One thing to note: if I use this code:

private void TestFunction()
{
Process proc;
proc = Process.GetCurrentProcess();
string procName = proc.ProcessName; <-- HANGS HERE
Console.WriteLine(procName);
}

The "proc =" assignment returns as expected. But if I try to examine
the properties of "proc" (in the debugger), "proc" it looks like an
uninitialized object.
Then the "procName=" line hangs (or appears to hang).

I still need to try elimintating all the unnecessary processes and
waiting longer, (as suggested by Nicholas) to see if that allows the
app to work.

But I don't understand why the "proc=" line return what appears to be
an improperly init'd object.

Thanks for your help.

-tomas

Tomas Vera said:
Hello All,
I'ma having trouble getting GetCurrentProcess() to work properly.
What I'm trying to accomplish is list all running processes. But my
call get GetProcesses() hangs.

While testing things out I found that the tiny program listed below
hangs as well.

Am I missing something?

-tomas


//---- This app hangs ----
using System;
using System.Diagnostics;

namespace proctest
{

class Class1
{

[STAThread]
static void Main(string[] args)
{

Console.WriteLine(Process.GetCurrentProcess().ProcessName);
}
}
}

// -- What's wrong with this code?

This tiny program should return within seconds. What version of XP (SP)
and
.NET are you running?
Are you running this as domain user or as a local user, how many user
tokens
do you have in you account group?

Willy.
 
Willy,
There is no difference when run from the IDE or from the command line.
There is no difference between RELEASE and DEBUG builds.


SP1 for .NET 1.1.4322 is NOT installed.

But, this is not critical, just fustrating. Just trying to learn
something new.

-tomas





Tomas,

How does this tiny program behaves when run from the commandline (in debug
or retail version).

Willy.
PS did you install SP1 for .NET 1.1.4322 ?


Tomas Vera said:
Willy,
I'm running in XP SP2 (.NET 1.1.4322)

I'm running as a local user on my laptop. Only 1 user on the machine.

One thing to note: if I use this code:

private void TestFunction()
{
Process proc;
proc = Process.GetCurrentProcess();
string procName = proc.ProcessName; <-- HANGS HERE
Console.WriteLine(procName);
}

The "proc =" assignment returns as expected. But if I try to examine
the properties of "proc" (in the debugger), "proc" it looks like an
uninitialized object.
Then the "procName=" line hangs (or appears to hang).

I still need to try elimintating all the unnecessary processes and
waiting longer, (as suggested by Nicholas) to see if that allows the
app to work.

But I don't understand why the "proc=" line return what appears to be
an improperly init'd object.

Thanks for your help.

-tomas

Hello All,
I'ma having trouble getting GetCurrentProcess() to work properly.
What I'm trying to accomplish is list all running processes. But my
call get GetProcesses() hangs.

While testing things out I found that the tiny program listed below
hangs as well.

Am I missing something?

-tomas


//---- This app hangs ----
using System;
using System.Diagnostics;

namespace proctest
{

class Class1
{

[STAThread]
static void Main(string[] args)
{

Console.WriteLine(Process.GetCurrentProcess().ProcessName);
}
}
}

// -- What's wrong with this code?



This tiny program should return within seconds. What version of XP (SP)
and
.NET are you running?
Are you running this as domain user or as a local user, how many user
tokens
do you have in you account group?

Willy.
 
Tomas,

If you are trying to get existing instances of Excel and Word, you
shouldn't have to enumerate through the processes. You should be able to
use the static GetActiveObject method on the Marshal class to automate
running instances of Excel and Word.
 
Nicholas,
Thanks. I cam across that yesteday after my posts.
So this issue is "dead" for now.

FYI, the example program that I posted did eventually run to
completion. Still it took 4 minutes to enumerate 42 processes.

The same program runs in less than half a second on my machine at work
with 33+ processes.

So there's something amiss with my steup at home.

Is it possible that some anti-virus software (Norton) can interfere
with this app?

Regadless, thanks for your help!

-tomas
 
Back
Top