【发布时间】:2011-10-10 10:51:25
【问题描述】:
我在 Silverlight 4 应用程序中使用 RIA 服务 DomainContext 来加载数据。如果我使用 UI 线程的上下文,回调是否总是在 UI 线程上?
或者换一种说法,回调总是和调用在同一个线程上吗?
下面的一些示例代码说明了该场景...
private void LoadStuff()
{
MyDomainContext context = new MyDomainContext ();
context.Load(context.GetStuffQuery(), op =>
{
if (!op.HasError)
{
// Use data.
// Which thread am I on?
}
else
{
op.MarkErrorAsHandled();
// Do error handling
}
}, null
);
}
【问题讨论】:
标签: c# multithreading silverlight silverlight-4.0 wcf-ria-services