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
- RolePrincipal.cs
- DataGridViewComboBoxCell.cs
- TextEditorCharacters.cs
- Canonicalizers.cs
- ParallelActivityDesigner.cs
- _CookieModule.cs
- SpeakProgressEventArgs.cs
- DataFormat.cs
- ThemeInfoAttribute.cs
- EmptyEnumerator.cs
- coordinatorfactory.cs
- InsufficientExecutionStackException.cs
- WorkflowMarkupSerializationProvider.cs
- SqlStatistics.cs
- Keywords.cs
- WebPartCloseVerb.cs
- AnimationLayer.cs
- WindowsStatusBar.cs
- WhiteSpaceTrimStringConverter.cs
- AdornerPresentationContext.cs
- WebBrowserProgressChangedEventHandler.cs
- ExpressionBinding.cs
- PenCursorManager.cs
- peernodeimplementation.cs
- CellIdBoolean.cs
- SymmetricAlgorithm.cs
- Speller.cs
- NumericExpr.cs
- DataGridTablesFactory.cs
- FloatUtil.cs
- CompiledQuery.cs
- SqlDataSourceDesigner.cs
- GridViewCancelEditEventArgs.cs
- EventDriven.cs
- AdCreatedEventArgs.cs
- DynamicPropertyReader.cs
- DataBoundControlHelper.cs
- ObjectListCommandCollection.cs
- COM2ICategorizePropertiesHandler.cs
- ConnectorRouter.cs
- Attributes.cs
- WebMessageFormatHelper.cs
- EnumValAlphaComparer.cs
- Encoder.cs
- DeviceContext2.cs
- ControlAdapter.cs
- SchemaAttDef.cs
- Peer.cs
- HtmlControl.cs
- DynamicRouteExpression.cs
- RTLAwareMessageBox.cs
- PageCatalogPart.cs
- MultiplexingFormatMapping.cs
- compensatingcollection.cs
- SafeProcessHandle.cs
- WebPartTransformerCollection.cs
- Label.cs
- AxisAngleRotation3D.cs
- AdornerHitTestResult.cs
- ChtmlCommandAdapter.cs
- MimeReturn.cs
- DbConnectionStringCommon.cs
- ElementNotEnabledException.cs
- EventData.cs
- WarningException.cs
- PersianCalendar.cs
- CLSCompliantAttribute.cs
- LocatorPart.cs
- EventKeyword.cs
- StaticFileHandler.cs
- StylusButtonCollection.cs
- KeyedHashAlgorithm.cs
- CompositeTypefaceMetrics.cs
- XmlFormatWriterGenerator.cs
- HighlightComponent.cs
- StatusBarPanel.cs
- PrimaryKeyTypeConverter.cs
- ModelVisual3D.cs
- SettingsProviderCollection.cs
- SymmetricSecurityBindingElement.cs
- HexParser.cs
- ResourcePool.cs
- TagPrefixInfo.cs
- ReflectionHelper.cs
- ContentAlignmentEditor.cs
- MarginsConverter.cs
- SqlXmlStorage.cs
- XmlSchemaSimpleContentExtension.cs
- WebProxyScriptElement.cs
- mansign.cs
- SpecialFolderEnumConverter.cs
- _HeaderInfo.cs
- GridViewAutomationPeer.cs
- ComPlusSynchronizationContext.cs
- PreProcessor.cs
- DataServices.cs
- WhitespaceRuleReader.cs
- GenerateHelper.cs
- XmlNamespaceManager.cs
- GridViewDeleteEventArgs.cs