Board index » Visual Studio » A Program To Check The Activities Of Another Program

A Program To Check The Activities Of Another Program

Visual Studio307
Hi,



We want to write a program (Prog_A) to check the activities of another

program (Prog_B). If there is no activity on the Prog_B for a period of time,

the Prog_A need send a message to close the Prog_B.



Is it possible to write a program to check the activities of another program

in C# ?



Thank you in advance!



David


-
 

Re:A Program To Check The Activities Of Another Program

david <david@discussions.microsoft.com>wrote:

Quote
We want to write a program (Prog_A) to check the activities of another

program (Prog_B). If there is no activity on the Prog_B for a period

of time, the Prog_A need send a message to close the Prog_B.



What do you mean by "activity"?

--

With best wishes,

Igor Tandetnik



With sufficient thrust, pigs fly just fine. However, this is not

necessarily a good idea. It is hard to be sure where they are going to

land, and it could be dangerous sitting under them as they fly

overhead. -- RFC 1925





-

Re:A Program To Check The Activities Of Another Program

Quote
We want to write a program (Prog_A) to check the activities of another

program (Prog_B). If there is no activity on the Prog_B for a period of

time,

the Prog_A need send a message to close the Prog_B.



Is it possible to write a program to check the activities of another

program

in C# ?



Thank you in advance!



You need to be more specific about what you're doing. Does "Prog_B" belong

to you for instance (so you can modify it as required) or is it some random

program you want to shut down if there's no activity. If so then no, it's

usually not possible to do it reliably or safely.





-

Re:A Program To Check The Activities Of Another Program

Thanks Igor and Larry.



The activity means the usage of the program, and Prog_B doesnâ??t belong to us.



We have a limit of licenses for this program (Prog_B). Some user might open

this program, but doesnâ??t really use it. In this case, it will be nice if we

can close it on his/her machine, and then another user can use it.



From what Larry said, it is not possible to do it. We will try to find other

solutions.



Thanks again,



David







"david" wrote:



Quote
Hi,



We want to write a program (Prog_A) to check the activities of another

program (Prog_B). If there is no activity on the Prog_B for a period of time,

the Prog_A need send a message to close the Prog_B.



Is it possible to write a program to check the activities of another program

in C# ?



Thank you in advance!



David

-

Re:A Program To Check The Activities Of Another Program

Quote
Thanks Igor and Larry.



The activity means the usage of the program, and Prog_B doesn't belong to

us.



We have a limit of licenses for this program (Prog_B). Some user might

open

this program, but doesn't really use it. In this case, it will be nice if

we

can close it on his/her machine, and then another user can use it.



From what Larry said, it is not possible to do it. We will try to find

other

solutions.



While you can monitor its CPU usage if you really want, and attempt to shut

it down if there's little activity, there's really no practical way to know

when activity has dropped completely to zero (or if it will pick up again

the moment you try to close it). More importantly perhaps, you can't cleanly

shut it down anyway since you don't know what it's doing at the time.

Perhaps it's in the middle of saving something to disk for instance so if

you terminate it then you do so at your own risk (potentially corrupting

something). If you know for sure that it's safe to do this however depending

on the nature of the app, and it will continue to be safe when future

versions are released (big assumption), then see here for details.



support.microsoft.com/kb/178893">support.microsoft.com/kb/178893





-

Re:A Program To Check The Activities Of Another Program

"Larry Smith" wrote:



Quote
While you can monitor its CPU usage if you really want, and attempt to shut

it down if there's little activity, there's really no practical way to know

when activity has dropped completely to zero (or if it will pick up again

the moment you try to close it). More importantly perhaps, you can't cleanly

shut it down anyway since you don't know what it's doing at the time.

Perhaps it's in the middle of saving something to disk for instance so if

you terminate it then you do so at your own risk (potentially corrupting

something). If you know for sure that it's safe to do this however depending

on the nature of the app, and it will continue to be safe when future

versions are released (big assumption), then see here for details.



support.microsoft.com/kb/178893">support.microsoft.com/kb/178893





Thank you for the good idea about monitoring CPU usage. It might be a

practical way in my case. I will try it out.



Thanks,



David



-

Re:A Program To Check The Activities Of Another Program



"Larry Smith" <no_spam@_nospam.com>wrote in message

Quote
>Thanks Igor and Larry.

>

>The activity means the usage of the program, and Prog_B doesn't belong to

>us.

>

>We have a limit of licenses for this program (Prog_B). Some user might

>open

>this program, but doesn't really use it. In this case, it will be nice if

>we

>can close it on his/her machine, and then another user can use it.

>

>From what Larry said, it is not possible to do it. We will try to find

>other

>solutions.



While you can monitor its CPU usage if you really want, and attempt to

shut it down if there's little activity, there's really no practical way

to know when activity has dropped completely to zero (or if it will pick

up again the moment you try to close it). More importantly perhaps, you

can't cleanly shut it down anyway since you don't know what it's doing at

the time. Perhaps it's in the middle of saving something to disk for

instance so if you terminate it then you do so at your own risk

(potentially corrupting something). If you know for sure that it's safe to

do this however depending on the nature of the app, and it will continue

to be safe when future versions are released (big assumption), then see

here for details.



If you post it WM_CLOSE instead of terminating the process, you are a lot

less likely to cause data loss.





-

Re:A Program To Check The Activities Of Another Program

On Wed, 18 Apr 2007 12:08:03 -0700, david

<david@discussions.microsoft.com>wrote:



Quote
"Larry Smith" wrote:



>While you can monitor its CPU usage if you really want, and attempt to shut

>it down if there's little activity, there's really no practical way to know

>when activity has dropped completely to zero (or if it will pick up again

>the moment you try to close it). More importantly perhaps, you can't cleanly

>shut it down anyway since you don't know what it's doing at the time.

>Perhaps it's in the middle of saving something to disk for instance so if

>you terminate it then you do so at your own risk (potentially corrupting

>something). If you know for sure that it's safe to do this however depending

>on the nature of the app, and it will continue to be safe when future

>versions are released (big assumption), then see here for details.

>

>support.microsoft.com/kb/178893">support.microsoft.com/kb/178893





Thank you for the good idea about monitoring CPU usage. It might be a

practical way in my case. I will try it out.



Thanks,



David



depending on the program maybe you could send it messages and examine

the reactions of the program, thay way you can get a hint if it is

still reacting. of course this only works if it is a gui program with

a message q.



hth/ajk

-