internal void BeginExecuteQuery(DataServiceContext context) { IAsyncResult result = null; BaseAsyncResult.PerRequest pereq = new BaseAsyncResult.PerRequest(); BaseAsyncResult.AsyncStateBag state = new BaseAsyncResult.AsyncStateBag(pereq, context); pereq.Request = this.Request; base.perRequest = pereq; try { if ((this.requestContentStream != null) && (this.requestContentStream.Stream != null)) { if (this.requestContentStream.IsKnownMemoryStream) { this.Request.SetContentLengthHeader(); } base.perRequest.RequestContentStream = this.requestContentStream; result = BaseAsyncResult.InvokeAsync(new Func <ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetRequestStream), this.Request, new AsyncCallback(this.AsyncEndGetRequestStream), state); } else { result = BaseAsyncResult.InvokeAsync(new Func <ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetResponse), this.Request, new AsyncCallback(this.AsyncEndGetResponse), state); } pereq.SetRequestCompletedSynchronously(result.CompletedSynchronously); base.SetCompletedSynchronously(result.CompletedSynchronously); } catch (Exception exception) { base.HandleFailure(exception); throw; } finally { this.HandleCompleted(pereq); } }
internal void BeginCreateNextChange() { HttpWebResponse response; this.inMemoryResponseStream = new MemoryStream(); BaseAsyncResult.PerRequest pereq = null; IAsyncResult result = null; Label_000F: response = null; ODataRequestMessageWrapper requestMessage = null; try { if (base.perRequest != null) { base.SetCompleted(); System.Data.Services.Client.Error.ThrowInternalError(InternalError.InvalidBeginNextChange); } requestMessage = this.CreateNextRequest(); if (requestMessage == null) { base.Abortable = null; } if ((requestMessage != null) || (base.entryIndex < base.ChangedEntries.Count)) { if (base.ChangedEntries[base.entryIndex].ContentGeneratedForSave) { goto Label_0191; } base.Abortable = requestMessage; BaseAsyncResult.ContentStream stream = this.CreateNonBatchChangeData(base.entryIndex, requestMessage); base.perRequest = pereq = new BaseAsyncResult.PerRequest(); pereq.Request = requestMessage; BaseAsyncResult.AsyncStateBag state = new BaseAsyncResult.AsyncStateBag(pereq, (DataServiceContext)base.Source); if ((stream == null) || (stream.Stream == null)) { result = BaseAsyncResult.InvokeAsync(new Func <ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetResponse), requestMessage, new AsyncCallback(this.AsyncEndGetResponse), state); } else { if (stream.IsKnownMemoryStream) { requestMessage.SetContentLengthHeader(); } pereq.RequestContentStream = stream; result = BaseAsyncResult.InvokeAsync(new Func <ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetRequestStream), requestMessage, new AsyncCallback(this.AsyncEndGetRequestStream), state); } pereq.SetRequestCompletedSynchronously(result.CompletedSynchronously); base.SetCompletedSynchronously(pereq.RequestCompletedSynchronously); } else { base.SetCompleted(); if (base.CompletedSynchronously) { this.HandleCompleted(pereq); } } } catch (InvalidOperationException exception) { WebUtil.GetHttpWebResponse(exception, ref response); this.HandleOperationException(exception, response); this.HandleCompleted(pereq); } finally { if (response != null) { response.Close(); } } if (((pereq != null) && pereq.RequestCompleted) && (pereq.RequestCompletedSynchronously && !base.IsCompletedInternally)) { this.FinishCurrentChange(pereq); } Label_0191: if (((pereq == null) || (pereq.RequestCompleted && pereq.RequestCompletedSynchronously)) && !base.IsCompletedInternally) { goto Label_000F; } }