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?
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.
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.
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?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.