Just to clarify: IResult and coroutines are not intended to be used with async stuff (which presently is only available in CTP).
IResult are mainly aimed to encapsulate a long async operation in a class, so that it could be "started" by the framework at a certain point in time, after the user has properly configured it (they are basically built around
So, if you have an async service call, or you have an operation that spawns multiple thread, to call it in a coroutine you should:
- wrap it into an IResult implementation
- start the operation on Execute body
- raise the Completed event when the operation actually ends
Some general purpose IResult implementation are available in
Caliburn source code (ShellFramework project).
Coroutines are a basically a way to delay the configuration of the next IResult to be executed at the latest time.
The framework expects an ordered set of IResult to be executed, one at time (IEnumerable<IResult>).
You *might* simply return an array or a list, but you have to know which "steps" to call (i.e. which fully-configured IResult instances to return) in advance.
C# iterator allows you to decide the next step in the sequence based on the result of the previous one, thus allowing a simple imperative programming in routines containing asyncronous parts.
I don't have a specific sample at hand, but this Rob's article could definitely help (it refers to Caliburn, not CM, but the call syntax is identical): http://devlicio.us/blogs/rob_eisenberg/archive/2009/07/10/asynchronous-execution-animation-and-more-in-mvvm-with-caliburn.aspx