PC Review


Reply
Thread Tools Rate Thread

? about checking an array of processes for activity

 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      26th Sep 2005
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,

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


"D" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
 
D
Guest
Posts: n/a
 
      26th Sep 2005
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


 
Reply With Quote
 
D
Guest
Posts: n/a
 
      27th Sep 2005
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 )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>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
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking wep page activity Paul Johnson Freeware 0 22nd Jun 2005 07:01 PM
Checking PDA Activity =?Utf-8?B?Um9iIFM=?= Microsoft Dot NET Compact Framework 0 6th Apr 2005 11:09 AM
Checking Processes Dakkar Microsoft C# .NET 2 29th Jan 2005 09:53 PM
Checking on modem activity ?? Dominik Jeske Microsoft Dot NET 0 22nd Nov 2003 08:39 PM
Applications stay as active processes with high CPU activity if exited while they are still loading LaVerne Microsoft Windows 2000 0 5th Sep 2003 01:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:15 PM.