I've run into problems when using Serial Coroutines with respect to the ManagedThreadId property on the EntityManager. The exception specifically says that I should "Consider calling the EntityManager’s asynchronous methods; they work safely on background threads managed by DevForce. " I thought I was using the asynchronous methods so I was expecting it to work. An example of the code is as follows:
public void TestCoroutine(AsyncEventCompletedCallback<GenericAsyncEventArgs<int>> callback) { //Get the entity manager from somewhere var myEntityManager = Uow.EntityManager;
Coroutine.Start( () => BuildBasicCoroutine(myEntityManager), op => { //Always fails }); }
private static IEnumerable<INotifyCompleted> BuildBasicCoroutine(DataModelEntityManager em) { yield return em.Users.ExecuteAsync(); yield return em.Contracts.ExecuteAsync(); } |
If I switch it to use Coroutine.StartParallel it will succeed just fine but in many cases I actually need serial behavior becaues one query depends on a previous query.
It seems like this should be possible and maybe I'm just doing something basic wrong. Any help would be appreciated.