Is there an example on how to write a custom coroutine operation? What I mean is a custom operation that implements INotifyCompleted or inherits from BaseOperation. All of the documentation I've found so far shows how to write the producer and consumer, and the producer is always yield returning DevForce operations such as EntityQueryOperation or EntitySaveOperation. We're looking to have our coroutine execute a custom web service as one of the operation steps but I'm having trouble determining how to implement INotifyCompleted. There's only 1 method to implement. It seems fairly clear that the WhenCompleted() method should be called when the web service finishes it's async processing, but who supplies the completedAction? Something like this:
private IEnumerable<INotifyCompleted> CoroutineProducer()
{
var op1 = em.Customers.Where().ExecuteAsync();
yield return op1;
var op2 =WebServiceExecutor.ExecuteAsync();
yield return op2;
var op3 = em.SaveChanges();
yield return op3;
}
static public class WebServiceExecutor
{
static public WebServiceOperation ExecuteAsync()
{
var op = new WebServiceOperation();
op.Start();
return op;
}
}
public class WebServiceOperation : INotifyCompleted
{
public void Start()
{
WebServiceClient client = new WebServiceClient();
client.SomeMethodCompleted += (completedArgs) =>
{
WhenCompleted(/* but what Action do I pass? */ null);
};
client.SomeMethod();
}
public WhenCompleted(Action<INotifyCompletedArgs> completedAction)
{
if (completedAction != null)
completedAction(new WebServiceOperationCompletedArgs());
}
}
I feel like I must be missing something obvious, but I can't seem to connect the dots. Am I heading about this all wrong?