By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

GetProcesses hangs on XP

P: n/a
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().Proc essName);
}
}
}

// -- What's wrong with this code?
Nov 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:8g********************************@4ax.com...
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().Proc essName);
}
}
}

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

Nov 17 '05 #2

P: n/a
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
On Thu, 13 Oct 2005 11:38:07 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
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?


Nov 17 '05 #3

P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:p3********************************@4ax.com...
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
On Thu, 13 Oct 2005 11:38:07 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
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?

Nov 17 '05 #4

P: n/a

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:8g********************************@4ax.com...
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().Proc essName);
}
}
}

// -- 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.

Nov 17 '05 #5

P: n/a
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
On Thu, 13 Oct 2005 13:46:53 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
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.


Nov 17 '05 #6

P: n/a
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

On Thu, 13 Oct 2005 22:37:22 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:8g********************************@4ax.com.. .
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().Proc essName);
}
}
}

// -- 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.


Nov 17 '05 #7

P: n/a
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" <ta**********@sbcglobalREMOVE.net> wrote in message
news:3o********************************@4ax.com...
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

On Thu, 13 Oct 2005 22:37:22 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:8g********************************@4ax.com. ..
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().Proc essName);
}
}
}

// -- 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.

Nov 17 '05 #8

P: n/a
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

On Fri, 14 Oct 2005 00:53:13 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:
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" <ta**********@sbcglobalREMOVE.net> wrote in message
news:3o********************************@4ax.com.. .
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

On Thu, 13 Oct 2005 22:37:22 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:8g********************************@4ax.com ...
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().Proc essName);
}
}
}

// -- 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.


Nov 17 '05 #9

P: n/a
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 Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tomas Vera" <ta**********@sbcglobalREMOVE.net> wrote in message
news:3h********************************@4ax.com...
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
On Thu, 13 Oct 2005 13:46:53 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
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.

Nov 17 '05 #10

P: n/a
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
On Fri, 14 Oct 2005 12:28:23 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
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.


Nov 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.