mirror of
https://github.com/Ellpeck/Coroutine.git
synced 2024-12-22 09:09:23 +01:00
parent
fa4d021368
commit
a3af44becb
3 changed files with 8 additions and 1 deletions
|
@ -11,7 +11,6 @@ namespace Coroutine {
|
|||
|
||||
internal ActiveCoroutine(IEnumerator<IWait> enumerator) {
|
||||
this.enumerator = enumerator;
|
||||
this.enumerator.MoveNext();
|
||||
}
|
||||
|
||||
public bool Cancel() {
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace Coroutine {
|
|||
private static readonly List<ActiveCoroutine> EventCoroutines = new List<ActiveCoroutine>();
|
||||
|
||||
public static ActiveCoroutine Start(IEnumerator<IWait> coroutine) {
|
||||
if (!coroutine.MoveNext())
|
||||
return null;
|
||||
var inst = new ActiveCoroutine(coroutine);
|
||||
var type = inst.GetCurrentType();
|
||||
if (type == WaitType.Tick)
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace Test {
|
|||
var seconds = CoroutineHandler.Start(WaitSeconds());
|
||||
CoroutineHandler.Start(PrintEvery10Seconds(seconds));
|
||||
|
||||
CoroutineHandler.Start(EmptyCoroutine());
|
||||
|
||||
CoroutineHandler.InvokeLater(new WaitSeconds(10), () => {
|
||||
Console.WriteLine("Raising test event");
|
||||
CoroutineHandler.RaiseEvent(TestEvent);
|
||||
|
@ -53,5 +55,9 @@ namespace Test {
|
|||
}
|
||||
}
|
||||
|
||||
private static IEnumerator<IWait> EmptyCoroutine() {
|
||||
yield break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue