Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Time Limit
#1
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:

Code:
Copy      Help
;;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 ?
#2
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
Code:
Copy      Help
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
#3
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.
#4
Function EndThisThreadAfter
Code:
Copy      Help
;/
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
#5
Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)