473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

? about checking an array of processes for activity

D
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
Nov 17 '05 #1
2 2257
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" <Da**@nothing.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

Nov 17 '05 #2
D
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:%2****************@TK2MSFTNGP12.phx.gbl... 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" <Da**@nothing.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Deepak Sarda | last post by:
Hello everyone. I have run into something which I believe is a bug or a shortcoming of the threading.Thread module. My program spawns 15 threads. For this I've creating a new class with...
1
by: Yannick Turgeon | last post by:
Hello all, I'm using SS 2000 and NT4 (and Access97 as front-end on another server) Well, probably by lack of knowledge about table locks, I don't really know where to start to present this...
2
by: Bruce Sandell | last post by:
I have a c# application where I run a query every 10 seconds. After the query completes, I close the connection object, close the oledbdatareader object and dispose of the command object. ...
2
by: Chris | last post by:
I need to know exactly what VBA lines Create and Destroy SQL Server Processes - i.e. those visible in Enterprise Manager under Management > Current Activity > Process Info. Why? I am...
15
by: Dirk Reske | last post by:
Hello, why doesn't this code work correctly? private int GetCpuUsage(Process proc) { DateTime time1,time2; TimeSpan timediff; double cpu1,cpu2,cpudiff;
5
by: kd | last post by:
Hi All, If the name of a process is known, is it possible to check whether it is in execution? What I did was to fetch all the processes running on the system using Process.GetProcesses() and...
4
by: microsoft.public.sqlserver.programming | last post by:
I am seeing sql processes (seen under Current Activity->process Info) exploding into over 100 processes even though hardly anyone is using it. It is an ASP.NET application, and I religiously...
5
by: fluk | last post by:
Hi Guys, I hope someone can help me with this, because i'm getting crazy to find a good way to do that! This is what I got by querying a db. $arr1 = array("site", "description", "area1" ,...
0
by: Mike Williams | last post by:
I don't know whether anyone from Microsoft regularly reads the Visual Basic groups but if they do then I am very surprised that they permit one of their own MVPs to engage in such outrageous long...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.