bool InternalAddMessage(Message message, TimeSpan timeout, object state, bool isLast) { MessageAttemptInfo attemptInfo; TimeoutHelper helper = new TimeoutHelper(timeout); try { if (isLast) { if (state != null) { throw Fx.AssertAndThrow("The isLast overload does not take a state."); } attemptInfo = this.strategy.AddLast(message, helper.RemainingTime(), null); } else if (!this.strategy.Add(message, helper.RemainingTime(), state, out attemptInfo)) { return(false); } } catch (TimeoutException) { if (isLast) { this.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.id, SR.GetString(SR.SequenceTerminatedAddLastToWindowTimedOut), null)); } // else - RM does not fault the channel based on a timeout exception trying to add a sequenced message to the window. throw; } catch (Exception e) { if (!Fx.IsFatal(e)) { this.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.id, SR.GetString(SR.SequenceTerminatedUnknownAddToWindowError), null)); } throw; } if (sendGuard.Enter()) { try { this.sendHandler(attemptInfo, helper.RemainingTime(), false); } catch (QuotaExceededException) { this.RaiseFault(null, SequenceTerminatedFault.CreateQuotaExceededFault(this.id)); throw; } finally { this.sendGuard.Exit(); } } return(true); }
private bool InternalAddMessage(Message message, TimeSpan timeout, object state, bool isLast) { MessageAttemptInfo info; TimeoutHelper helper = new TimeoutHelper(timeout); try { if (isLast) { if (state != null) { throw Fx.AssertAndThrow("The isLast overload does not take a state."); } info = this.strategy.AddLast(message, helper.RemainingTime(), null); } else if (!this.strategy.Add(message, helper.RemainingTime(), state, out info)) { return(false); } } catch (TimeoutException) { if (isLast) { this.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.id, System.ServiceModel.SR.GetString("SequenceTerminatedAddLastToWindowTimedOut"), null)); } throw; } catch (Exception exception) { if (!Fx.IsFatal(exception)) { this.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.id, System.ServiceModel.SR.GetString("SequenceTerminatedUnknownAddToWindowError"), null)); } throw; } if (this.sendGuard.Enter()) { try { this.sendHandler(info, helper.RemainingTime(), false); } catch (QuotaExceededException) { this.RaiseFault(null, SequenceTerminatedFault.CreateQuotaExceededFault(this.id)); throw; } finally { this.sendGuard.Exit(); } } return(true); }
private void OnBinderException(IReliableChannelBinder sender, Exception exception) { if (exception is QuotaExceededException) { this.session.OnLocalFault(exception, SequenceTerminatedFault.CreateQuotaExceededFault(this.session.OutputID), null); } else { base.EnqueueAndDispatch(exception, null, false); } }
private void OnBinderException(IReliableChannelBinder sender, Exception exception) { if (exception is QuotaExceededException) { if (((base.State == CommunicationState.Opening) || (base.State == CommunicationState.Opened)) || (base.State == CommunicationState.Closing)) { this.session.OnLocalFault(exception, SequenceTerminatedFault.CreateQuotaExceededFault(this.session.OutputID), null); } } else { base.AddPendingException(exception); } }
private void CompleteSend(IAsyncResult result) { try { this.connection.endSendHandler(result); } catch (QuotaExceededException) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateQuotaExceededFault(this.connection.id)); throw; } finally { this.connection.sendGuard.Exit(); } }
private bool CompleteAdd(IAsyncResult result) { MessageAttemptInfo attemptInfo = new MessageAttemptInfo(); this.validAdd = true; try { if (this.isLast) { attemptInfo = this.connection.strategy.EndAddLast(result); } else if (!this.connection.strategy.EndAdd(result, out attemptInfo)) { this.validAdd = false; return(true); } } catch (TimeoutException) { if (this.isLast) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.connection.id, System.ServiceModel.SR.GetString("SequenceTerminatedAddLastToWindowTimedOut"), null)); } throw; } catch (Exception exception) { if (!Fx.IsFatal(exception)) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.connection.id, System.ServiceModel.SR.GetString("SequenceTerminatedUnknownAddToWindowError"), null)); } throw; } if (this.connection.sendGuard.Enter()) { bool flag = true; try { result = this.connection.beginSendHandler(attemptInfo, this.timeoutHelper.RemainingTime(), false, sendCompleteStatic, this); flag = false; } catch (QuotaExceededException) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateQuotaExceededFault(this.connection.id)); throw; } finally { if (flag) { this.connection.sendGuard.Exit(); } } } else { return(true); } if (result.CompletedSynchronously) { this.CompleteSend(result); return(true); } return(false); }
bool CompleteAdd(IAsyncResult result) { MessageAttemptInfo attemptInfo = default(MessageAttemptInfo); this.validAdd = true; try { if (this.isLast) { attemptInfo = this.connection.strategy.EndAddLast(result); } else if (!this.connection.strategy.EndAdd(result, out attemptInfo)) { this.validAdd = false; return(true); } } catch (TimeoutException) { if (this.isLast) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.connection.id, SR.GetString(SR.SequenceTerminatedAddLastToWindowTimedOut), null)); } // else - RM does not fault the channel based on a timeout exception trying to add a sequenced message to the window. throw; } catch (Exception e) { if (!Fx.IsFatal(e)) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateCommunicationFault(this.connection.id, SR.GetString(SR.SequenceTerminatedUnknownAddToWindowError), null)); } throw; } if (this.connection.sendGuard.Enter()) { bool throwing = true; try { result = this.connection.beginSendHandler(attemptInfo, this.timeoutHelper.RemainingTime(), false, sendCompleteStatic, this); throwing = false; } catch (QuotaExceededException) { this.connection.RaiseFault(null, SequenceTerminatedFault.CreateQuotaExceededFault(this.connection.id)); throw; } finally { if (throwing) { this.connection.sendGuard.Exit(); } } } else { return(true); } if (result.CompletedSynchronously) { this.CompleteSend(result); return(true); } else { return(false); } }