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
- HwndTarget.cs
- FullTextLine.cs
- SrgsRuleRef.cs
- ToolStripManager.cs
- StorageEntityTypeMapping.cs
- ChannelReliableSession.cs
- XmlSchemaAnyAttribute.cs
- SplashScreen.cs
- Matrix3DValueSerializer.cs
- GraphicsContext.cs
- ListViewTableRow.cs
- EnumerableRowCollectionExtensions.cs
- MissingMethodException.cs
- DesignTimeParseData.cs
- WebResourceUtil.cs
- SynchronizedKeyedCollection.cs
- LogRecordSequence.cs
- XmlSchemaObjectTable.cs
- HttpServerChannel.cs
- CodeDomExtensionMethods.cs
- DataColumnMapping.cs
- RichTextBoxAutomationPeer.cs
- SystemGatewayIPAddressInformation.cs
- XdrBuilder.cs
- FileUtil.cs
- BamlLocalizabilityResolver.cs
- NamespaceEmitter.cs
- PasswordBoxAutomationPeer.cs
- ImageMap.cs
- JsonReader.cs
- XXXInfos.cs
- DataPagerFieldCollection.cs
- ContentFileHelper.cs
- PaperSize.cs
- ListViewHitTestInfo.cs
- WindowsGraphics2.cs
- TypeElement.cs
- DesignerTransaction.cs
- WeakReference.cs
- EventSetterHandlerConverter.cs
- TripleDES.cs
- _AutoWebProxyScriptHelper.cs
- PointConverter.cs
- ModelPropertyImpl.cs
- HashSetEqualityComparer.cs
- HtmlInputReset.cs
- RestHandler.cs
- StylusDownEventArgs.cs
- DiscardableAttribute.cs
- serverconfig.cs
- TypeUtil.cs
- Point3DValueSerializer.cs
- XPathDescendantIterator.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- CqlGenerator.cs
- FacetChecker.cs
- WebControlAdapter.cs
- XmlSchemaInclude.cs
- TreeViewEvent.cs
- XmlWrappingReader.cs
- EditingCommands.cs
- BuildProviderCollection.cs
- KeyPressEvent.cs
- EventTrigger.cs
- ZipIOLocalFileDataDescriptor.cs
- __ComObject.cs
- DoubleLink.cs
- IMembershipProvider.cs
- WindowPatternIdentifiers.cs
- ControlBindingsCollection.cs
- XmlCDATASection.cs
- TraceLevelStore.cs
- FixedSchema.cs
- XmlHierarchicalDataSourceView.cs
- KeyEventArgs.cs
- ValidationErrorCollection.cs
- ReverseComparer.cs
- SetterBaseCollection.cs
- SafeFileHandle.cs
- DataColumnChangeEvent.cs
- FrameworkElement.cs
- InputBindingCollection.cs
- Mutex.cs
- BitmapEffectGeneralTransform.cs
- ActionFrame.cs
- Condition.cs
- Matrix3DValueSerializer.cs
- ProfessionalColors.cs
- InlineCollection.cs
- TextFragmentEngine.cs
- DefaultIfEmptyQueryOperator.cs
- NumberSubstitution.cs
- BinaryConverter.cs
- DbDeleteCommandTree.cs
- ImageButton.cs
- WebControlsSection.cs
- UITypeEditor.cs
- SqlDataReader.cs
- CodeCommentStatementCollection.cs
- SiteMapProvider.cs