Print Page | Close Window

Is Cocktail Syncing when Syncing is turned off?

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4122
Printed Date: 20-Sep-2025 at 2:32am


Topic: Is Cocktail Syncing when Syncing is turned off?
Posted By: JohnBloom
Subject: Is Cocktail Syncing when Syncing is turned off?
Date 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



Replies:
Posted By: mgood
Date 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. 



Print Page | Close Window