I'm trying to use a job control in one job to call another job. I want to wait (sleep) if that other job is running. Multple instances won't really work, so i need to have the controlling job wait to call the job once it has finished.
I'd like to just look up the job status on that job, but I don't have a handle since it was called by a separate process.
The next thing I tried was to run the job DSAttacheJob and if it didn't work, wait (sleep) and try again later. I'm just not quite sure how to make that work.
call another job from job control and wait if it is running
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 2
- Joined: Tue Dec 07, 2004 1:35 pm
Welcome! You can get the status using the command line program dsjob without needing a job handle. Otherwise, you can try to use DSAttach and see the value returned from a DSGetJobInfo and see if the return value is DSJE.BADHANDLE. I never tried it, but the DS BASIC documentation has to be correct, right?
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Wait a minute, what do I mean welcome? You've been lurking quite a awhile. How about: Thanks for piping up!
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
-
- Participant
- Posts: 232
- Joined: Fri Sep 30, 2005 4:52 am
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
DSAttachJob() is necessary before issuing the run request with DSRunJob(). So retrying that function isn't going to help; it's still attached to the controller while it's running.
Try creating a new server job, open its job properties then the Job Control tab. Select a job from the drop down list and click Add Job. Inspect the generated code; it will show you how DSWaitForJob is used.
If you need to use Sleep for some other reason (for example a busy loop that does other things in the meantime) then you need to write a loop that checks to see if the job is still running.
This is not a perfect solution, but will get you started.
Try creating a new server job, open its job properties then the Job Control tab. Select a job from the drop down list and click Add Job. Inspect the generated code; it will show you how DSWaitForJob is used.
If you need to use Sleep for some other reason (for example a busy loop that does other things in the meantime) then you need to write a loop that checks to see if the job is still running.
Code: Select all
Loop
While DSGetJobStatus(hJob, DSJ.JOBSTATUS) = DSJS.RUNNING
* do other things
Sleep 2 ; * sleep for two seconds
Repeat ; * loop exits once status is no longer "running"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
The stated issue is that if ControlJob#1 has attached and started TransformJob, how can ControlJob#2 attached to TransformJob and see its status? I don't believe two jobs can have a job handle for the same job simultaneously, but maybe I'm wrong.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
-
- Participant
- Posts: 2
- Joined: Tue Dec 07, 2004 1:35 pm
I'm doing this in the job control of a job, so it is in the BASIC. I can't user the dsjob command from there. But your other suggestion works - I get a return value of 0 if the job is already running. THANKS!!!!
kcbland wrote:Welcome! You can get the status using the command line program dsjob without needing a job handle. Otherwise, you can try to use DSAttach and see the value returned from a DSGetJobInfo and see if the return value is DSJE.BADHANDLE. I never tried it, but the DS BASIC documentation has to be correct, right?
CatieHannah
Okay, but you can always issue system command line commands via a CALL DSExecute(....). You can run dsjob as a command. Search the forum for DSExecute for ways folks have used it.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle