Im running an application and pulling data from its screen. But sometimes the application freezes. It has nothing to do with the QM code, but the application im controling has a bug or a network induced timeout.
What I would like to do is to create a seporate thread, that will be set to cound down from, say 10 to 0. One step every second. The main program will be responsible to reset the counter value to 10 very frequently. So, if the value reaches 0, it will indicate that the main program is hung.
I belive this technique is called a watchDog timer.
I tryed to create a seporate macro using
mac "watchDogThread"
But it does not create a async thread. The watchDogThread only runs when the main thread exits.
I know its a simple mistake but Im not shure what Im doing wrong.
This sets count down value to a high number and prevents the system from killing the program.
But if the program ever hangs the watchDog will wait for 5 min and close the program with
clo watchExec_handle
Gintras, QM is great stuff!!! I was a bit taken aback by the entire change in paradyme but now Im a believer.... It remindes me of an environemnt i worked with years ago called "forth". The environment yes, the language no. Once again, great contributuion. Thanks Gintras...
dll user32 #IsHungAppWindow hWnd
act "My Dialog"
int xWindow=win
rep
if(IsHungAppWindow(xWindow))
ShutDownProcess xWindow
break
..
If I am using dll user32 #IsHungAppWindow hWnd in main macro and also in a function, should I also add the same line in the Function? Or having it on the main macro is good enough? The function is separate from the main macro, its a trigger.
Identical declarations in multiple places is not error, but better put it in a single place. Somewhere so that the function would be declared before it is called. For example, in function init2 (if init2 does not exist - create), which runs at startup.
The code should have a wait command, or it will consume much CPU time. Also should check whether the window still exists, or IsHungAppWindow will endlessly return 0 checking dead window handle.
There are many intances I have ran into though, where the window is still there, but cannot close it, where I have to go to Task Manager to close it. So this function will only work if the window does not exist?
IsHungAppWindow returns 1 if the window exists but is not responding >5 seconds.
ShutDownProcess2 kills the program like Task Manager but without any dialogs. the program can be hung or not. It can have windows or not. ShutDownProcess too, but does not accept program name, only window handle.
Gintaras Wrote:ShutDownProcess2 kills the program like Task Manager but without any dialogs. the program can be hung or not. It can have windows or not. ShutDownProcess too, but does not accept program name, only window handle.
New QM versions add more features to some functions. In QM 2.1.8.5, with ShutDownProcess you can use either window handle or program name. Before QM 2.1.8.5, program name cannot be used. Version 2.1.8.6 will add more features, eg terminate all matching processes.