Is it necessary to error check each coroutine operation's error state after each yield return or is it eoungh to handle errors in the Coroutine completed callback? (Is the red highlighted code below necessary?)
Without the use of a Coroutine, my code would look something like the following, with error checked after each async call has completed:
private void LoadData() {
em.Customers.Where().ExecuteAsync((customerArgs) =>
{
if (customerArgs.HasError) { // handle error } else
{
em.Orders.Where().ExecuteAsync((orderArgs) =>
{
if (orderArgs.HasError) { // handle error } else
{
} }); } }); }
|
Translating to Coroutine, my code is:
private void LoadData() { Coroutine.Start(CoroutineActions, (completed) => { if (completed.HasError) { // handle error } else {
} }); }
private IEnumerable<INotifyCompleted> CoroutineActions() { var op1 = em.Customers.Where().ExecuteAsync(); yield return op1;
// Do I have to continue to error check after each async operation, or
// is it ok to skip this?
if (op1.HasError) { // handle error } else { var op2 = em.Orders.Where().ExecuteAsync(); yield return op2; } }
|