Forum Discussion
I have created this kind of method. I've called it "fluentWait". (I use javascript)
this method wait dynamically for an object to be exists in the object tree. (100ms interval, up to 10sec)
function fluentWait(){
let stopTime = GetTickCount() + 10000; //wait 10s at max
do {
var obj = Aliases.your.main.container.WaitNamedChild(MappedChildName, 100);
}
while(! obj.Exists && GetTickCount() < stopTime);
}
- tristaanogre2 years agoEsteemed Contributor
That works. However, two things:
1) I'd make the stop time be calculated based upon an input parameter. Instead of hardcoding 10 seconds, make that the input parameter for the user to enter the number of milliseconds to wait.2) MappedChildName needs to be an input parameter as well. Somehow, you need to indicate the name that you want to wait for.
3) The problem is that the named child, in the indicated code, must be an immediate child of the your.main.container object. What if it's not? Somehow you need to indicate the parent that you want to search under
4) WaitNamedChild cannot take alias names, only mapped names. If you want to search based upon Alias, you should use WaitAliasChild but then, again, you need to designate the parent.
Here's how I'd re-write it:function fluentWait(parentObject, childName, waitTime){ let stopTime = GetTickCount() + waitTime; //wait 10s at max do { var obj = parentObject.WaitAliasChild(childName, 100); } while(! obj.Exists && GetTickCount() < stopTime); }
Related Content
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago