The serial Coroutine allows you to batch up async actions, but you can certainly intersperse synchronous logic and function calls within the iterator block. In what you're showing here CalculateFormula is a synchronous call, so you can call it within your iterator block. In this case "B" should also be doing something async, otherwise why bother with the Coroutine.
You only need to use yield return when "yielding" due to an async operation. When you start an async operation you yield, and execution of the block resumes when the operation completes. A synchronous call does not require a yield.
Also, the (optional) Coroutine.Return() result which you can return from an iterator block is not truly the same thing as the INotifyCompleted object which you yield return when awaiting the completion of the async operation. The Return(x) is just a handy way to return a result back to the caller, it's returned to the Coroutine completion handler in the Result property of the event args. So here, you could setup your call like this:
var op = Coroutine.Start(B);
op.Completed += (s,e) => {
var result = e.Result;
}
or this:
Coroutine.Start(B, op => {
var result = op.Result;
});
Edited by kimj - 03-Dec-2010 at 3:23pm