can you please tell me, how to start a task and then wait until it ends in VBScript?
I tried, but I don't know VBScript.
It seems, that between starting a task and checking its status, I need to wait for a few seconds. But I'm not sure.
My version for "Delay" makes the CPU busy, there should be a better way.
Are status 3 and 4 the right values for checking if the task is still running?
Thank you.
Code: Select all
extName = "hallo_task"
num = RoboTaskApp().StartTask(extName, "")
'Delay
mytime = timer
do while timer < mytime + 5
loop
num = RoboTaskApp().TaskNumByExternalName(extName)
if num >=0 then
'Still running?
st = RoboTaskApp().TaskInfoState(num)
do while st = 3 or st = 4
st = RoboTaskApp().TaskInfoState(num)
loop
en = RoboTaskApp().TaskEnabled(extName)
TaskName = RoboTaskApp().TaskInfoName(num)
RoboTaskApp().DesktopAlert _
"Task information", _
"Task Name: " + TaskName + "; " + Chr(10) + _
"Task number: " + CStr(num) + "; " + Chr(10) + _
"Task status: " + Cstr(st) + "(" + stName + "); " + Chr(10) + _
"Is the task enabled: " + Cstr(en) + ";", _
0, 0, 10, 0, 100, 3
else
RoboTaskApp().DesktopAlert _
"Task information", _
"Unknown task External name" + chr(10) + _
"The task desn't exist", _
2, 0, 10, 0, 100, 3
end if