Make sure Enumerator resources get cleaned up.

This commit is contained in:
Anna Rose 2025-02-11 14:00:28 -05:00
parent be989a233d
commit 6fd7d5dda5
2 changed files with 5 additions and 3 deletions

View File

@ -96,6 +96,7 @@ namespace IngameScript
_program.Runtime.UpdateFrequency |= UpdateFrequency.Once;
yield return true;
}
job.Dispose();
while (Triggered) yield return true;

View File

@ -12,16 +12,16 @@ namespace IngameScript
public class Sequencer
{
public bool Running { get; private set; }
public string Name { get; private set; }
private IConsole _console;
private string _name;
private SortedDictionary<int, List<ISequenceable>> _sequence = new SortedDictionary<int, List<ISequenceable>>();
public Sequencer(IConsoleProgram program, string name)
{
_name = name;
_console = new PrefixedConsole(program.Console, _name);
Name = name;
_console = new PrefixedConsole(program.Console, Name);
}
public void AddBlock(ISequenceable block)
@ -66,6 +66,7 @@ namespace IngameScript
}
yield return true;
}
foreach (IEnumerator<bool> subJob in subJobs) subJob.Dispose(); // clean up after ourselves
}
}
}