Skip to content

Stopping coroutines when WaitAny == true (?) #1

@petejonze

Description

@petejonze

I'm not very familiar with coroutines, but I couldn't see any obvious way to terminate all remaining/active coroutines when using WaitAny (as it currently is, the remaining coroutines could keep running in the background indefinitely).

To do so I added a new line of code to Wrapper. It seems to work, but I don't know whether it is good practice:

        private IEnumerator Wrapper(IEnumerator e, int index)
        {
            while (true)
            {
                if(e != null && e.MoveNext())
                {
                    _wait[index] = true; 
                    yield return e.Current;
                }
                else
                {
                    _wait[index] = false;
                    break;
                }

                if (!keepWaiting) { yield break; } // NEW LINE: to quit all coroutines once WaitAny no longer returns true (?????)
            }
        } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions