I have this code:
public IEnumerable<ImportRecord> Parse()
{
var engine = new FileHelperAsyncEngine<Record>();
using (StreamReader reader = new StreamReader(this.stream))
using (engine.BeginReadStream(reader))
{
foreach (var record in engine)
{
yield return record.Convert(this.correlationId);
}
}
}
A stream is opened and the function starts yielding results.
My understanding is the enumerable state machine is having to hold the state of the opened stream causing some sort of overhead?
Could there be a situation where the streams aren't disposed, say if you did this: Parse().Skip(10).Take(1);
where you aren't enumerating the entire sequence? My guess is no, I would assume the state machine would do something, I'm unsure as to what that something is if someone could elaborate.