0
我想寫一個wcf數據服務的異步調用,但不知道如何讀取返回的對象。Asynch WCF數據服務/ OData
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總是給我空:(
我有調試它,但不能得到任何線索。我猜這是與線程有關的東西,我必須將值傳遞給我的主線程,但不知道如何做到這一點:( – user2463514