Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if a programm is still running.

Status
Not open for further replies.

cspm2003

Programmer
Nov 24, 2004
78
DE
Hello,

I have written a vb6 program and want to check every minute or so if a different programm is still running. I just did an endless loop and inserted a sleep statement in the loop. Is there a better way of doing this?

cheers
 
use an API Timer - do a search here

You say "check...if...still running". If your application has started another application and is to wait until it finishes, then maybe try and use the APIs CreateProcess and WaitForSingleObject - also do a search here.
 
Out of interest, why would an API Timer be a better way than a loop with Sleep in it?
 
Timer vs. Sleep? Did I say that? I didn't say that.

Timer vs. Loop

Anyways, Timer vs. Loop or Timer vs. Sleep, Better?
Guess it depends on what is being done. I just gave some options.

Not much more help can be given with-out knowing if the called programm is a Visible task or not (because of effects using Sleep or WaitForSingleObject, meaning a need to use a minimal timeout, add a doevents, and locking the calling application), and if in the calling has some other task already running which also needs to be suspended.

Just assuming that the called programm is an application, in which it is desired that the calling application should simply be suspended or locked until the called programm is closed (Simply: a user wants to start see a picture, clicks on a button and for this a picture viewer is started, suspending the calling applicaiton) and no tasks in the calling application are running (this being called inside of another proceedure and waiting on a result).

But, cspm2003 asked the question, so it more help is needed then they can further question.
 
Fine.

It was just that given that the question in the original post of "Is there a better way of doing this?" led immediately to your unqualified reply of "Use an API timer" led me to believe that you had a reason to make such an answer.


 

What makes you think using a timer is an unqualified reply?
And should we not answer any questions at all with-out specifics?
Assuming the purpose again, I would consider a timer and disabling the application, if nothing else is running it the app., and if the called programm is an application and just waiting for it to be closed by the user.
Is that so bad of an option?
 
Im checking on an open TCP Port. Then I would use my method, right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top