Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / TimeoutStream.cs / 1 / TimeoutStream.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.IO; // Enforces an overall timeout based on the TimeoutHelper passed in class TimeoutStream : DelegatingStream { TimeoutHelper timeoutHelper; public TimeoutStream(Stream stream, ref TimeoutHelper timeoutHelper) : base(stream) { if (!stream.CanTimeout) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("stream", SR.GetString(SR.StreamDoesNotSupportTimeout)); } this.timeoutHelper = timeoutHelper; } void UpdateReadTimeout() { this.ReadTimeout = TimeoutHelper.ToMilliseconds(this.timeoutHelper.RemainingTime()); } void UpdateWriteTimeout() { this.WriteTimeout = TimeoutHelper.ToMilliseconds(this.timeoutHelper.RemainingTime()); } public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { UpdateReadTimeout(); return base.BeginRead(buffer, offset, count, callback, state); } public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { UpdateWriteTimeout(); return base.BeginWrite(buffer, offset, count, callback, state); } public override int Read(byte[] buffer, int offset, int count) { UpdateReadTimeout(); return base.Read(buffer, offset, count); } public override int ReadByte() { UpdateReadTimeout(); return base.ReadByte(); } public override void Write(byte[] buffer, int offset, int count) { UpdateWriteTimeout(); base.Write(buffer, offset, count); } public override void WriteByte(byte value) { UpdateWriteTimeout(); base.WriteByte(value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BindingExpressionBase.cs
- SelectionRange.cs
- ping.cs
- SourceFilter.cs
- DataContractJsonSerializer.cs
- ListViewDeleteEventArgs.cs
- ParenthesizePropertyNameAttribute.cs
- KeyTimeConverter.cs
- StreamSecurityUpgradeAcceptor.cs
- BoundConstants.cs
- TimeSpanValidator.cs
- ValidateNames.cs
- SoapFault.cs
- NetMsmqBinding.cs
- TcpPortSharing.cs
- IndependentAnimationStorage.cs
- Expander.cs
- DataGridViewCellCancelEventArgs.cs
- Configuration.cs
- ScriptManagerProxy.cs
- ChannelSinkStacks.cs
- Helpers.cs
- EntityRecordInfo.cs
- FileLoadException.cs
- UnicodeEncoding.cs
- SamlAuthorizationDecisionStatement.cs
- XmlBoundElement.cs
- GeneralTransform2DTo3DTo2D.cs
- RuntimeTransactionHandle.cs
- TextRangeSerialization.cs
- WebCodeGenerator.cs
- ScrollBarRenderer.cs
- ToolStripItemEventArgs.cs
- CharEntityEncoderFallback.cs
- Context.cs
- FormViewPagerRow.cs
- SeverityFilter.cs
- PropertyToken.cs
- RequestBringIntoViewEventArgs.cs
- FactoryId.cs
- _NegotiateClient.cs
- BitConverter.cs
- Animatable.cs
- PackageStore.cs
- ProxyElement.cs
- StoreItemCollection.cs
- FieldToken.cs
- InvalidProgramException.cs
- DocobjHost.cs
- DecoderBestFitFallback.cs
- CaseStatementProjectedSlot.cs
- JavaScriptObjectDeserializer.cs
- ConfigDefinitionUpdates.cs
- ProfileProvider.cs
- ComponentDispatcher.cs
- TrackingStringDictionary.cs
- InstanceKeyCompleteException.cs
- PenThreadWorker.cs
- PropertyChangingEventArgs.cs
- AuthorizationContext.cs
- _NegoStream.cs
- DesignerFrame.cs
- _ShellExpression.cs
- EntityDataSourceSelectingEventArgs.cs
- RequestCache.cs
- ChildrenQuery.cs
- PageSetupDialog.cs
- TrustManagerPromptUI.cs
- WindowsListViewItemStartMenu.cs
- SafeRightsManagementQueryHandle.cs
- SubclassTypeValidatorAttribute.cs
- XmlQuerySequence.cs
- TreeViewImageKeyConverter.cs
- MergePropertyDescriptor.cs
- MediaTimeline.cs
- EdmScalarPropertyAttribute.cs
- HitTestWithGeometryDrawingContextWalker.cs
- Bits.cs
- CorrelationManager.cs
- ThrowHelper.cs
- XmlSchemaObject.cs
- DataGridViewRowsRemovedEventArgs.cs
- ValueChangedEventManager.cs
- CommentEmitter.cs
- EDesignUtil.cs
- DbConnectionPoolOptions.cs
- NativeRecognizer.cs
- FocusManager.cs
- TextElement.cs
- MenuItemStyleCollection.cs
- BufferedWebEventProvider.cs
- CompositeDesignerAccessibleObject.cs
- SqlCrossApplyToCrossJoin.cs
- CatalogZoneBase.cs
- PreservationFileReader.cs
- CachedBitmap.cs
- UpdateCommand.cs
- DefaultIfEmptyQueryOperator.cs
- LeaseManager.cs
- ManagementEventWatcher.cs