我正在尝试编写对 wcf 数据服务的异步调用,但不确定如何读取返回的对象。
public IQueryable<T> Read(string TableName)
{
IQueryable<T> OdataResult=null;
IAsyncResult asyncresult = context.BeginExecute<T>(new Uri("/" + TableName, UriKind.Relative),
(result) =>
{
Dispatcher.CurrentDispatcher.BeginInvoke(new OperationResultCallback(delegate
{
var result1 = new DataServiceCollection<T>(context.EndExecute<T>(result));
OdataResult = result1.AsQueryable<T>();
}), null);
}, null);
asyncresult.AsyncWaitHandle.WaitOne();
asyncresult.AsyncWaitHandle.Close();
return OdataResult;}
ODataResult 总是给我 null :(