Posts: 100
Threads: 45
Joined: Jan 2014
Guys,
how can I put a time limit for each Function running in my Macro?
I've created a .exe to run the macro below:
;;Macro 1
rep 3
FUNCTION_1 ;err
FUNCTION_2 ;err
err 5; continue
break
But, sometimes, the Function 1 or 2 take more than 30 min to run. I'd like to limit the running time by just 1min for each function.
Could you pls help me ?
Posts: 12,075
Threads: 141
Joined: Dec 2002
Usually it's better to put a limit-time code in the function.
If not, need to execute the function in other thread, like this:
Macro
Macro2738
int timeLimit=3 ;;seconds
rep 1
,int ht
,ht=mac("sub.FUNCTION_1")
,wait timeLimit H ht; err EndThread "" ht
,ht=mac("sub.FUNCTION_2")
,wait timeLimit H ht; err EndThread "" ht
#sub FUNCTION_1
mes 1
#sub FUNCTION_2
mes 2
Posts: 100
Threads: 45
Joined: Jan 2014
Thank you!
Just trying to simplify...do you know how can I make a .exe, which will ShutDown after 120seconds automatically?
I'm having a bad time creating another .exe to shutdown the process.
Posts: 12,075
Threads: 141
Joined: Dec 2002
Function
EndThisThreadAfter
;/
function ^timeS
;Schedules to end this thread after timeS seconds.
;If it is the first thread in .exe, then .exe process also will end.
;EXAMPLE
;EndThisThreadAfter 3
;mes "macro"
QMTHREAD qt; GetQmThreadInfo 0 qt
mac "sub.ET" "" timeS qt.threadhandle
#sub ET
function ^timeS ht
wait timeS
EndThread "" ht
Posts: 100
Threads: 45
Joined: Jan 2014