You need to enumerate the collection, You just check whether the result is null
or not, that will not start the enumeration.
foreach (var frame in GameState.MainLoop())
{
//Do whatever with frame
}
To make it work with `foreach
you can make the MainLoop
method return IEnumerable<GameFrame>
instead of IEnumerator<GameFrame>
Or just use
var enumerator = GameState.MainLoop();
while (enumerator.MoveNext())
{
//Do whatever with enumerator.Current
}