The callback will always be called in the user interface thread. If the request used the XmlHttp stack (which is the default if you call it from the user interface thread), the network stack calls the callback registered by the WCF data service in the user interface thread. Thus, in this case, this is the behavior of the DataServiceCollection / DataServiceContext, but the behavior of the underlying network stack. If you call a request from a thread other than the UI, or you explicitly set the Http stack by the client, then the callback will return to the thread other than the UI (potentially different). We still transfer it back to the user interface thread before informing the caller. The reason for this is consistency, especially since you cannot interact with user interface elements in the background thread.
If you execute the request manually, for example, through DataServiceContext.BeginExecute, then the materialization (or most of it) will be called by the caller, since the call returns only IEnumerable, which is not yet filled. If you then pass execution to the workflow and list the results there, materialization will occur in that thread.
Just curious why you want to move it? Are you processing so much data that it causes visible user interface lags?
source share