New Posts New Posts RSS Feed: Is Cocktail Syncing when Syncing is turned off?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Is Cocktail Syncing when Syncing is turned off?

 Post Reply Post Reply
Author
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Topic: Is Cocktail Syncing when Syncing is turned off?
    Posted: 23-Apr-2013 at 1:43pm
We never used the entitymanager syncing capabilities in Cocktail. We recently started getting this error on some of our saves:

Exception has been thrown by the target of an invocation.
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at DomainServices.Models.BaseEntitiesRepository`1.<Save>d__8.MoveNext()
   
 An EntityManager can only execute on a single thread. This EntityManager is authorized to execute on the thread with id=’8’; the requested operation came from the thread with Id=‘1’.

You may have to disable this cross-thread checking for specific reasons such as automated testing. Please review our documentation on multi-threading issues and the EntityManager.AuthorizedThreadId property.
   at IdeaBlade.EntityModel.EntityManager.SafeThreadingCheck()
   at IdeaBlade.EntityModel.EntityManager.ImportEntities(IEnumerable entities, MergeStrategy mergeStrategy)
   at Cocktail.EntityManagerProvider`1.Caliburn.Micro.IHandle<Cocktail.SyncDataMessage<T>>.Handle(SyncDataMessage`1 syncData)

It appears that this is being thrown by an entity manager that is trying to sync up its changes. We are calling save changes from an event so that is why the two managers would be on different threads. However we never added a sync interceptor and according to the documentation there is not syncing by default. I am still getting the problem even if I have an interceptor that returns false for importing and exporting. What am I doing wrong?
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 24-Apr-2013 at 11:37am
Yes, the syncing logic always triggers. The default sync interceptor just returns false. You need to ensure that all EntityManagers are created on the UI thread. 

Why is your event handler called on a different thread? What is triggering the event? You can use the SynchronizationContext or Caliburn.Micro's Execute.OnUIThread to dispatch your handler code to the UI thread. 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down