I've got a couple of questions/concerns regarding coroutines.
First, I'm curious as to why IEnumerator was used over IEnumerable. For a number of tasks I have I need to chain a few coroutines together. This has led me to implement the chaining using a while loop with MoveNext instead of a foreach. I find the foreach
a bit easier to read than the bare iterator approach.
The second issue I've run across is that an object I create that implements IResult and return to the coroutine seems to be garbage collected if it doesn't actually do anything in the Execute method. What I'm doing in the Execute is subscribing to the IEventAggregator.
Later it'll receive an event from the aggregator and run the Completed event. However, after about 1 second, it stops receiving events from the aggregator. I suspect it was collected because I can pin the object to a static variable and everything works as
it should. So the question is, why are my objects being collected? I suspect I'll have to craft a sample to illustrate the point, however, I've got a deadline on this project so I'm not sure when I'd get around to it.
The basic gist of what I'm trying to accomplish is a vector drawing program. I'm using coroutines to wait for mouse input, do work, wait for more mouse input, and loop around again and do it all over again.