Silverlight 中的同步 ADO.NET 数据服务调用 [英] Synchronous ADO.NET dataservices calls in Silverlight

查看:29
本文介绍了Silverlight 中的同步 ADO.NET 数据服务调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Silverlight 应用程序中使用 ADO.NET 数据服务,并且由于 Silverlight 库不支持 IQueryable 上的 ToList() 调用,我认为可以围绕该方法创建一个名为 SilverlightToList() 的扩展方法.所以在这个方法中,我在我的上下文中调用 BeginExecute 方法,如下所示:

I'm using ADO.NET dataservices in a Silverlight application and since the silverlight libraries don't support the ToList() call on the IQueryable I thought it might be possible to create an extension method around this called SilverlightToList(). So in this method I'm calling the BeginExecute method on my context as shown below:

            var result = context.BeginExecute<T>(currentRequestUri,null,context);
            result.AsyncWaitHandle.WaitOne();
            return context.EndExecute<T>(result).ToList();

问题是,当我调用 WaitOne() 方法时,这会导致死锁.这是 Silverlight 中 ADO.NET 数据服务的限制吗?可能有解决方法吗?

The problem is that when I call the WaitOne() method this results in a deadlock. Is this a limitation of ADO.NET dataservices in Silverlight? Is there perhaps a workaround for this?

推荐答案

我发现了 这篇帖子在 MSDN 论坛上说,任何托管->非托管->托管编组都发生在 UI 线程上,这解释了为什么 WaitOne 方法调用挂起......

I've since found this post on the MSDN forum which says that any managed->UnManaged->Managed marshalling happens on the UI thread which explains why the WaitOne method call is hanging...

这篇关于Silverlight 中的同步 ADO.NET 数据服务调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆