Print Page | Close Window

InvokeServerMethodAsync - threading problems?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2750
Printed Date: 28-Apr-2025 at 2:51am


Topic: InvokeServerMethodAsync - threading problems?
Posted By: danjal
Subject: InvokeServerMethodAsync - threading problems?
Date Posted: 09-Jun-2011 at 9:59am

I have a datagrid that contains some data.

In this grid, there is an expand button. When the user clicks this button a nested grid appears, with data that belongs to the specific row.

The data for the nested grid come from a InvokeServerMethodAsync call that is called the first time the user hits this expand button. This works fine.

 

Then I added a refresh functionality to the grid, that when used, refetches the data for the master grid and calls InvokeServerMethodAsync for the nested grids. This is where I get an error, which I think has something to do with the fact that I am calling the same InvokeServerMethodAsync many times within a short time frame.

But why is this a problem?

We are using Silverlight DevForce 6.0.9

Message: System.InvalidOperationException: An EntityManager can only execute on a single thread. This EntityManager is authorized to execute on the thread with id=’1’; the requested operation came from the thread with Id=‘53’. Consider calling the EntityManager’s asynchronous methods; they work safely on background threads managed by DevForce.  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.EntityQueriedEventArgs.get_Results()
   at IdeaBlade.EntityModel.EntityQueryOperation.get_Results()
   at IdeaBlade.EntityModel.ListEntityReference`1.QueryCallback(EntityQueryOperation op)
   at IdeaBlade.EntityModel.BaseOperation`2.OnCompleted()
   at IdeaBlade.EntityModel.BaseOperation`2.IdeaBlade.EntityModel.IHasAsyncEventArgs.OnCompleted()
   at IdeaBlade.EntityModel.AsyncProcessor`1.<>c__DisplayClass2.<.ctor>b__0(TArgs args)
   at IdeaBlade.EntityModel.AsyncProcessor`1.Signal()
   at IdeaBlade.EntityModel.AsyncProcessor`1.<CheckPreActionHasError>b__6(Object d)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()   

 




Replies:
Posted By: DenisK
Date Posted: 13-Jun-2011 at 11:55am
Hi danjal;

Could you post some code snippets of your InvokeServerMethod logic on the client?



Print Page | Close Window