Created
March 16, 2021 23:25
-
-
Save zaafar/0a4fa1a711e9e7bfb92fc7c4d83ec912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class Example { | |
private static IEnumerator<Wait> iwillnotrun() | |
{ | |
while (true) | |
{ | |
Console.WriteLine($"Inside iwillnotrun while loop"); | |
Console.WriteLine($"I should run forever."); | |
yield return new Wait(1); | |
Console.WriteLine($"iwillnotrun"); | |
Console.WriteLine($"iwillnotrun"); | |
Console.WriteLine($"iwillnotrun"); | |
Console.WriteLine($"iwillnotrun"); | |
} | |
} | |
private static IEnumerator<Wait> iwillalwaysrunforever() | |
{ | |
while (true) | |
{ | |
Console.WriteLine($"iwillalwaysrunforever"); | |
yield return new Wait(1); | |
} | |
} | |
private static IEnumerator<Wait> iwillrunonce() | |
{ | |
Console.WriteLine($"iwillalwaysrunforever"); | |
yield return new Wait(1); | |
CoroutineHandler.Start(iwillnotrun()); | |
} | |
public static void Main() { | |
CoroutineHandler.Start(iwillalwaysrunforever()); | |
CoroutineHandler.Start(iwillrunonce()); | |
var lastTime = DateTime.Now; | |
while (true) { | |
var currTime = DateTime.Now; | |
CoroutineHandler.Tick((currTime - lastTime).TotalSeconds); | |
lastTime = currTime; | |
Thread.Sleep(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment