static void OnCloseComplete(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; Exception exception = null; try { thisPtr.upgradeProvider.EndClose(result); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } exception = e; } thisPtr.Complete(false, exception); }
static void OnReleaseConnectionPoolScheduled(object state) { CloseAsyncResult thisPtr = (CloseAsyncResult)state; bool completeSelf; Exception completionException = null; try { completeSelf = thisPtr.OnReleaseConnectionPoolScheduled(); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completeSelf = true; completionException = e; } if (completeSelf) { thisPtr.Complete(false, completionException); } }
static bool HandleEndHostClose(IAsyncResult result) { CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; thisPtr.host.EndHostClose(result); return(thisPtr.CloseDurableInstanceManager()); }
static void OnClosePollerComplete(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; Exception completionException = null; bool completeSelf = false; try { completeSelf = thisPtr.CompleteClosePoller(result); } catch (Exception e) { completionException = e; completeSelf = true; } if (completeSelf) { thisPtr.Complete(false, completionException); } }
static void OnCloseInputSession(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; bool completeSelf = false; Exception completionException = null; try { completeSelf = thisPtr.HandleCloseInputSession(result, false); } #pragma warning suppress 56500 // [....], transferring exception to another thread catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completeSelf = true; completionException = e; } if (completeSelf) { thisPtr.Complete(false, completionException); } }
static void OnCloseComplete(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; Exception exception = null; try { thisPtr.communicationObject.EndClose(result); } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } exception = e; } thisPtr.Complete(false, exception); }
static bool OnCloseCompletion(IAsyncResult result) { CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; thisPtr.communicationObject.OnEndClose(result); thisPtr.NotifyClosed(); return(true); }
protected void CompleteClose(bool syncComplete, Exception exception) { CloseAsyncResult closeResult = Interlocked.Exchange(ref this.pendingClose, null); if (closeResult != null) { closeResult.Signal(syncComplete, exception); } }
static bool HandleDurableInstanceManagerEndClose(IAsyncResult result) { CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; thisPtr.host.durableInstanceManager.EndClose(result); thisPtr.host.WorkflowServiceHostPerformanceCounters.Dispose(); return(true); }
private static bool CompleteBaseClose(IAsyncResult result) { // AsyncResult.AsyncCompletionWrapperCallback takes care of catching exceptions for us. CloseAsyncResult <T> thisPtr = (CloseAsyncResult <T>)result.AsyncState; // We are completing the base class close operation at this point. thisPtr.baseEndClose(result); return(true); }
public void OnEndOuterListenerClose(IAsyncResult result) { if (result is CompletedAsyncResult) { CompletedAsyncResult.End(result); } else { CloseAsyncResult <TInnerChannel, TInnerItem> .End(result); } }
public void EndClose(IAsyncResult result) { if (result is AlreadyClosedAsyncResult) { CompletedAsyncResult.End(result); } else { CloseAsyncResult.End(result); } }
private static bool CompleteCloseOutputChannel(IAsyncResult result) { // AsyncResult.AsyncCompletionWrapperCallback takes care of catching exceptions for us. CloseAsyncResult <T> thisPtr = (CloseAsyncResult <T>)result.AsyncState; // We are completing the base class close operation at this point. thisPtr.channel.UdpOutputChannel.EndClose(result); thisPtr.channel.Cleanup(false, thisPtr.timeoutHelper.RemainingTime()); return(thisPtr.BeginBaseClose()); }
public void EndClose(IAsyncResult result) { if (result is CompletedAsyncResult) { CompletedAsyncResult.End(result); } else { AmqpTrace.Provider.AmqpLogOperationVerbose(this, TraceOperation.Execute, "EndClose"); CloseAsyncResult.End(result); } }
public IAsyncResult DefaultOnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { // Modify the placeholder async result we already instantiated. CloseAsyncResult.Callback = callback; CloseAsyncResult.AsyncState = state; // The mock always Completes the IAsyncResult before handing it back. // This is done because the sync path has no access to this IAsyncResult // that happens behind the scenes. CloseAsyncResult.Complete(); return(CloseAsyncResult); }
static bool OnInputSessionClosed(IAsyncResult result) { CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; using (Message message = thisPtr.channel.receiveQueue.EndDequeue(result)) { if (message != null) { throw CreateReceiveShutdownReturnedNonNull(message); } } thisPtr.channel.OnInputSessionClosed(); return(true); }
protected override void OnEndClose(IAsyncResult result) { try { CloseAsyncResult.End(result); this.TraceBaseAddresses(); ThreadTrace.StopTracing(); } catch (TimeoutException exception) { if (DiagnosticUtility.ShouldTraceWarning) { TraceUtility.TraceEvent(TraceEventType.Warning, 0x8002e, System.ServiceModel.SR.GetString("TraceCodeServiceHostTimeoutOnClose"), this, exception); } base.Abort(); } }
static void OnWaitForStopLater(object state) { CloseAsyncResult thisPtr = (CloseAsyncResult)state; Exception completionException = null; try { thisPtr.CompleteWaitForStop(); } catch (Exception e) { completionException = e; } thisPtr.Complete(false, completionException); }
public void EndClose(IAsyncResult result) { try { if (result is CompletedAsyncResult) { CompletedAsyncResult.End(result); } else { CloseAsyncResult.End(result); } } finally { this.NotifyClosed(); } }
static bool OnOutputSessionClosed(IAsyncResult result) { CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; thisPtr.channel.EndCloseOutputSession(result); if (thisPtr.channel.isInputSessionClosed) { return(true); } else { IAsyncResult closeInputSessionResult = thisPtr.channel.receiveQueue.BeginDequeue(thisPtr.timeouthelper.RemainingTime(), thisPtr.PrepareAsyncCompletion(CloseInputSessionCallback), thisPtr); if (!closeInputSessionResult.CompletedSynchronously) { return(false); } return(OnInputSessionClosed(closeInputSessionResult)); } }
static void OnCompleteCloseScheduled(object state) { CloseAsyncResult thisPtr = (CloseAsyncResult)state; Exception completionException = null; try { thisPtr.OnCompleteCloseScheduled(); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completionException = e; } thisPtr.Complete(false, completionException); }
private static void OnCloseComplete(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; Exception exception = null; try { thisPtr._communicationObject.EndClose(result); } catch (Exception e) { exception = e; } thisPtr.Complete(false, exception); }
static void OnCloseChannelComplete(IAsyncResult result) { if (result.CompletedSynchronously) { return; } CloseAsyncResult thisPtr = (CloseAsyncResult)result.AsyncState; Exception completionException = null; try { thisPtr.CompleteCloseChannel(result); } catch (Exception e) { completionException = e; } thisPtr.Complete(false, completionException); }
private static void CompleteCleanup(object state, TimeoutException exception) { CloseAsyncResult thisPtr = (CloseAsyncResult)state; Exception completionException = null; if (exception != null) { Fx.Assert(exception.GetType() == typeof(TimeoutException), "Exception on callback should always be TimeoutException"); throw FxTrace.Exception.AsError(new TimeoutException(SR.TimeoutOnOperation(thisPtr.timeoutHelper.OriginalTimeout))); } try { lock (thisPtr.channel.ThisLock) { thisPtr.channel.retransmissionDoneWaitHandle = null; // another thread could have called Abort while Close() was waiting for retransmission to complete. if (!thisPtr.channel.cleanedUp) { // never aborting here thisPtr.channel.CleanupAfterWait(false); } } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completionException = e; } thisPtr.Complete(false, completionException); }
public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state) { if (timeout < TimeSpan.Zero) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("timeout", System.ServiceModel.SR.GetString("SFxTimeoutOutOfRange0"))); } using ((DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose) ? this.CreateCloseActivity() : null) { CommunicationState state2; lock (this.ThisLock) { state2 = this.state; if (state2 != CommunicationState.Closed) { this.state = CommunicationState.Closing; } this.closeCalled = true; } switch (state2) { case CommunicationState.Created: case CommunicationState.Opening: case CommunicationState.Faulted: this.Abort(); if (state2 == CommunicationState.Faulted) { throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this); } return new AlreadyClosedAsyncResult(callback, state); case CommunicationState.Opened: { bool flag = true; try { this.OnClosing(); if (!this.onClosingCalled) { throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this); } IAsyncResult result = new CloseAsyncResult(this, timeout, callback, state); flag = false; return result; } finally { if (flag) { if (DiagnosticUtility.ShouldTraceWarning) { TraceUtility.TraceEvent(TraceEventType.Warning, 0x80004, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectCloseFailed", new object[] { this.GetCommunicationObjectType().ToString() }), this); } this.Abort(); } } break; } case CommunicationState.Closing: case CommunicationState.Closed: break; default: throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState"); } return new AlreadyClosedAsyncResult(callback, state); } }
protected virtual void OnClose(TimeSpan timeout) { CloseAsyncResult.End(new CloseAsyncResult(this, timeout, null, null)); }
static void OnWaitCompleted(object state, TimeoutException asyncException) { CloseAsyncResult thisPtr = (CloseAsyncResult)state; thisPtr.Complete(false, asyncException); }
public void EndClose(IAsyncResult result) { CloseAsyncResult.End(result); }
protected override void OnEndClose(IAsyncResult result) { CloseAsyncResult <TChannel> .End(result); }
protected override void OnEndClose(IAsyncResult result) { CloseAsyncResult <QueueItemType> .End(result); }
public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state) { if (timeout < TimeSpan.Zero) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("timeout", SR.GetString(SR.SFxTimeoutOutOfRange0))); using (DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose ? this.CreateCloseActivity() : null) { CommunicationState originalState; lock (ThisLock) { originalState = this.state; #if DEBUG if (closeStack == null) closeStack = new StackTrace(); #endif if (originalState != CommunicationState.Closed) this.state = CommunicationState.Closing; this.closeCalled = true; } switch (originalState) { case CommunicationState.Created: case CommunicationState.Opening: case CommunicationState.Faulted: this.Abort(); if (originalState == CommunicationState.Faulted) { throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this); } return new AlreadyClosedAsyncResult(callback, state); case CommunicationState.Opened: { bool throwing = true; try { OnClosing(); if (!this.onClosingCalled) throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this); IAsyncResult result = new CloseAsyncResult(this, timeout, callback, state); throwing = false; return result; } finally { if (throwing) { if (DiagnosticUtility.ShouldTraceWarning) { TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.CommunicationObjectCloseFailed, SR.GetString(SR.TraceCodeCommunicationObjectCloseFailed, this.GetCommunicationObjectType().ToString()), this); } Abort(); } } } case CommunicationState.Closing: case CommunicationState.Closed: return new AlreadyClosedAsyncResult(callback, state); default: throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState"); } } }
public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state) { if (timeout < TimeSpan.Zero) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("timeout", System.ServiceModel.SR.GetString("SFxTimeoutOutOfRange0"))); } using ((DiagnosticUtility.ShouldUseActivity && this.TraceOpenAndClose) ? this.CreateCloseActivity() : null) { CommunicationState state2; lock (this.ThisLock) { state2 = this.state; if (state2 != CommunicationState.Closed) { this.state = CommunicationState.Closing; } this.closeCalled = true; } switch (state2) { case CommunicationState.Created: case CommunicationState.Opening: case CommunicationState.Faulted: this.Abort(); if (state2 == CommunicationState.Faulted) { throw TraceUtility.ThrowHelperError(this.CreateFaultedException(), Guid.Empty, this); } return(new AlreadyClosedAsyncResult(callback, state)); case CommunicationState.Opened: { bool flag = true; try { this.OnClosing(); if (!this.onClosingCalled) { throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnClosing"), Guid.Empty, this); } IAsyncResult result = new CloseAsyncResult(this, timeout, callback, state); flag = false; return(result); } finally { if (flag) { if (DiagnosticUtility.ShouldTraceWarning) { TraceUtility.TraceEvent(TraceEventType.Warning, 0x80004, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectCloseFailed", new object[] { this.GetCommunicationObjectType().ToString() }), this); } this.Abort(); } } break; } case CommunicationState.Closing: case CommunicationState.Closed: break; default: throw Fx.AssertAndThrow("CommunicationObject.BeginClose: Unknown CommunicationState"); } return(new AlreadyClosedAsyncResult(callback, state)); } }