I am trying to write asynch call to a wcf data service but not sure how to read the object returned.
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 is always giving me null :(
I have used "Task" instead of "Dispatcher" and it shared the Data via "Result" property with My main thread.