我试图按照使用Silverlight 4测试版执行WCF数据服务查询的模式。以下是我的代码:Silverlight 4访问WCF数据服务:BeginInvoke沮丧
public CodeTables()
{
CodeCountries = new ObservableCollection<dsRealHomes.CodeCountries>();
dsRealHomes.RealHomesEntities myClient = null;
myClient = staticGlobals.RealHomesContext();
object userState = null;
myClient.BeginExecute<dsRealHomes.CodeCountries>(new Uri("CodeCountries"),
(IAsyncResult asyncResult) =>
{
Dispatcher.BeginInvoke(
() =>
{
var test = myClient.EndExecute<dsRealHomes.CodeCountries>asyncResult).ToList();
}
);
}, userState);
}
这是从一些例子我已经遇到了在Silverlight WCF数据服务的。不幸的是,无论我如何努力实现我的“Dispatcher.BeginInvoke”结束与下面的错误代码:
“的对象引用需要非静态字段,方法或属性(系统。 Windows.Threading.Dispatcher.BeginInvoke(System.Action)”