? about checking an array of processes for activity

  • Thread starter Thread starter Ignacio Machin \( .NET/ C# MVP \)
  • Start date Start date
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I'm sure of what you want to do, what are those processes?
You dont' have an "idle" process as you have an idle threadpool spot.

Maybe if you explain what you are trying to achieve you will get better
suggestions

Maybe what you want is using threads, and not processes.



cheers,
 
I have an array of processes declared like so

System.Diagnostics.Process[] _ProcessArray = new
System.Diagnostics.Process[_iProcessCount];

and the code below shows how I iterate thru the array and looking for a
"free" process to assign some work too. I'm not sure if the way I'm doing it
is the best way to do this, I didn't see any type of IsActive call on the
process object.

I'm thinking about making the processes signal the "scheduler" that they are
free via an event. I don't suppose there's a framerwork or sample code
around that does something similiar.

Thanks


while(bContinue)
{
for(iProcessIndex = 0; iProcessIndex < _iProcessCount; iProcessIndex++)
{
try
{
if(_ProcessArray[iProcessIndex].Id > 0)
{
if(_ProcessArray[iProcessIndex].HasExited)
{
bFreeProcess = true;
break;
}
}
}
catch(Exception e)
{
bFreeProcess = true;
break;
}
}

if(bFreeProcess)
{
. ....... give some work to the free process
 
Those processes are the System.Diagnostic.Process and are executing a few
win32 c++ programs I wrote. I create an array of them, initialize them and
set them running. The loop listed below just is a simple type scheduler.
While(bContinue) it checks to see which (if any) processes are free via

if(_ProcessArray[iProcessIndex].Id > 0)
{
if(_ProcessArray[iProcessIndex].HasExited)
{

I'm not sure if thats the best way to check if a process is active or not??

Thanks

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

I'm sure of what you want to do, what are those processes?
You dont' have an "idle" process as you have an idle threadpool spot.

Maybe if you explain what you are trying to achieve you will get better
suggestions

Maybe what you want is using threads, and not processes.



cheers,

-- I cr
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


D said:
I have an array of processes declared like so

System.Diagnostics.Process[] _ProcessArray = new
System.Diagnostics.Process[_iProcessCount];

and the code below shows how I iterate thru the array and looking for a
"free" process to assign some work too. I'm not sure if the way I'm doing
it is the best way to do this, I didn't see any type of IsActive call on
the process object.

I'm thinking about making the processes signal the "scheduler" that they
are free via an event. I don't suppose there's a framerwork or sample
code around that does something similiar.

Thanks


while(bContinue)
{
for(iProcessIndex = 0; iProcessIndex < _iProcessCount;
iProcessIndex++)
{
try
{
if(_ProcessArray[iProcessIndex].Id > 0)
{
if(_ProcessArray[iProcessIndex].HasExited)
{
bFreeProcess = true;
break;
}
}
}
catch(Exception e)
{
bFreeProcess = true;
break;
}
}

if(bFreeProcess)
{
. ....... give some work to the free process
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top