Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

WaitForIdle in OnPostReload - QV hangs

Hello,

is there any problem when using WaitForIdle in a macro which is triggered by OnPostReload (QV 8.5) ?

On Commandline (cmd.exe) I run a batch which calls "qv.exe /r /NoSecurity myfile.qvw"

I have defined a macro which shall run OnPostReload.
At the very beginning of that macro (it is literally the very first line after my logging code) I do WaitForIdle 5000 ... just to be sure that all effects of the reload are well processed.

Running the batch, the macro hangs at that line (I know that for sure due to 'Before ... After WaitForIdle logging code).
I can run the macro without problems from within the QV Window.
But during the batch, QV hangs at that line.

Any idea?
Thanks in advance,
Thilo

6 Replies
Not applicable
Author

Hi

WaitForIdle, when run from the command line, will simply stop the macro working and it will hang, every time!!

You should remove the WaitForIdle from the macro, maybe move it to a macro that is called only when a sheet object, or sheet itself is activated.

Not applicable
Author

Nigel,


Nigel West wrote:WaitForIdle, when run from the command line, will simply stop the macro working and it will hang, every time!!


I think I cannot agree. Meanwhile I did some further tests - letting run the commandline with the same (unchanged) qvw over and over again.
SOMETIMES it hangs in WaitForIdle, but sometimes it does not.

But still, why do you think the macro MUST stop?
I don't have any background on how WaitForIdle works ...

Thank you,
Thilo

Not applicable
Author

SOMETIMES it hangs in WaitForIdle, but sometimes it does not.


OK, so now you know more than me! My experience was that it hung every time I tried it, but maybe you have this macro activated in a different way somehow, the thing with this is that I lost the will to try to find out more, I simply removed it.

Not applicable
Author

Nigel,


Nigel West wrote:the thing with this is that I lost the will to try to find out more, I simply removed it


[:'(] I wish I could ...

Unfortunately WaitForIdle is a problem solver for another topic in that macro.
I experienced troubles in the 'current-ness' of the data when switching sheets, and WaitForIdle solved that.

Damn, it looks as if I am cornered by conflicting workarounds ...

Thank you,
Thilo

Not applicable
Author

Is there a way to separate the macros, so you still have the WaitForIdle working when switching sheets, but not on the post reload?

Also, would be interested to know how you are logging this, as this is something I need to get my head around pretty quickly.

Not applicable
Author

Nigel,


Nigel West wrote:Also, would be interested to know how you are logging


I simply use the FileSystemObject to create a log file.
The basics for the routine I found in this forum (while searching for OnPostReload topics).


' -------------------------------------------------------------------
' LogMessage
' -------------------------------------------------------------------
sub LogMsg(byval sMsg)
dim fso
dim logFile, sFile, txsStream
if DO_LOG = 0 then exit sub

set fso = CreateObject("Scripting.FileSystemObject")
sFile = LOGDIRECTORY & "\" &MYLOGFILE

on error resume next
set logFile = fso.GetFile(sFile)
if err <> 0 then ' file does not exist
on error goto 0
set logFile = fso.CreateTextFile(sFile)
else
on error goto 0
end if
set txsStream = logFile.OpenAsTextStream(8) ' append
txsStream.WriteLine Now & ": " & sMsg
txsStream.Close

set txsStream = nothing
set logFile = nothing
set fso = nothing
end sub


DO_LOG is a global const which I use to quickly enable/disable logging.
LOGDIRECTORY and MYLOGFILE are global const to define log location and name.

I use this function very frequently in my code.
With the DO_LOG switch I can easily disable the logging in a customer/ productive environment.

hth,
Thilo