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