开发者

Silverlight RIA Services: Running DomainContext on background thread

I am working on a OOB application that does document merging with MS Word.

I need to download the latest MS Word template files, and since this can take some time, I am trying to do so in the background.

Merely instantiating a domaincontext on any thread other than the UI thread throws a cross thread exception.

The easy fix would 开发者_如何学Pythonbe to instantiate the domaincontext on the UI thread, but that would defeat the object. Any workarounds? Anything I'm missing?

Regards, Derick


This is because the default constructor uses a relative url for the service. It needs to get the current application to find the base url. If you use one of the overloads that accepts urls and give it an absolute url it will work. (Hopefully :) ).


Pass the domaincontext as a paremater of RunWorkerAsync(context) and you should be ok. This then allows you to perform all query operations within the background thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜