Jump to content
iV - Ghost

waitUntil all childTasks are completed

Recommended Posts

How can I waitUntil all childTasks are completed?

 

 

private _childTask = _parentTask call BIS_fnc_taskChildren;
...

 

Share this post


Link to post
Share on other sites

Not tested but something like this perhaps?

waitUntil {count ("task_1" call BIS_fnc_taskChildren) isEqualTo 0};

 

Share this post


Link to post
Share on other sites

Does that not work? What are you trying to do? Check if a or all child task(s) are complete?

Maybe try:

(taskChildren "task_1" select 0) call BIS_fnc_taskCompleted

// also not tested:
{_x call BIS_fnc_taskCompleted} count (taskChildren "task_1")

 

  • Thanks 1

Share this post


Link to post
Share on other sites

@iV - Ghost, try this:

waitUntil {
    _subtasks = _taskId call BIS_fnc_taskChildren;

    ({_x call BIS_fnc_taskCompleted} count _subtasks) == (count _subtasks)
};

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
12 hours ago, Schatten said:

@iV - Ghost, try this:


waitUntil {

    _subtasks = _taskId call BIS_fnc_taskChildren;
    ({_x call BIS_fnc_taskCompleted} count _subtasks) == (count _subtasks);
    
};

 

 

This seems to be the right way.

Thx a lot for help.

Share this post


Link to post
Share on other sites

Can be optimized a little

waitUntil {
    _subtasks = _taskId call BIS_fnc_taskChildren;
    _subtasks findIf {!(_x call BIS_fnc_taskCompleted)} == -1 
};

findIf aborts at the first "true" it finds. So it doesn't always have to iterate over the whole list of tasks. As soon as it finds a task that is not completed it can just abort right away.

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×