private IAsyncResult GetResponse(AsyncCallback callback, Object asyncState) { Task <OdataWcfQuery> responseTask = _interceptor.OnGetResponse(this, _requestStream); var tcs = new TaskCompletionSource <OdataWcfQuery>(asyncState); responseTask.ContinueWith(t => { tcs.TrySetResult(t.Result); callback(tcs.Task); }); return(tcs.Task); }
private IAsyncResult GetResponse(AsyncCallback callback, Object asyncState) { Task <OdataWcfQuery> responseTask = _interceptor.OnGetResponse(this, _requestStream); var tcs = new TaskCompletionSource <OdataWcfQuery>(asyncState); responseTask.ContinueWith(t => { if (t.IsFaulted) { tcs.TrySetException(t.Exception); } else if (t.IsCanceled) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(t.Result); } callback(tcs.Task); }); return(tcs.Task); }