- Home /
Question by
supremegrandruler · Mar 19, 2015 at 08:49 PM ·
c#coroutineienumerator
How does WaitForSeconds actually work behind the scenes?
So I know yield is used with IEnumerator to return elements one by one, but how does the code know to resume the IEnumerator after X seconds?
Comment
Answer by AlwaysSunny · Mar 20, 2015 at 06:12 AM
This is not presented as a definitive answer (as though the writer is entirely certain) but it looks and sounds about right to me. For all intents and purposes I would assume his explanation is accurate: http://twistedoakstudios.com/blog/Post83_coroutines-more-than-you-want-to-know
So if I understand correctly the way WaitForSeconds() works is that it only moves to the next element in the IEnumerator by calling $$anonymous$$oveNext() if the timeDelta or some timer elapsed or w/e is greater than the parameter passed in to WaitForSeconds().