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
- ElementProxy.cs
- RowsCopiedEventArgs.cs
- Accessible.cs
- PropertyValidationContext.cs
- AutomationProperties.cs
- SQLInt16Storage.cs
- GroupBox.cs
- ClrProviderManifest.cs
- ProgressBarRenderer.cs
- ObsoleteAttribute.cs
- _BufferOffsetSize.cs
- Pts.cs
- __Error.cs
- ExpressionUtilities.cs
- ContentElement.cs
- XmlTextReaderImplHelpers.cs
- ElementFactory.cs
- HMACSHA256.cs
- NativeRecognizer.cs
- StringWriter.cs
- HealthMonitoringSection.cs
- CompareValidator.cs
- EdmScalarPropertyAttribute.cs
- HeaderUtility.cs
- GridViewDeleteEventArgs.cs
- FormCollection.cs
- PolicyStatement.cs
- DesignerToolStripControlHost.cs
- TreeViewItem.cs
- DataControlFieldCell.cs
- VisualTreeHelper.cs
- GPRECT.cs
- ControlPager.cs
- CommonDialog.cs
- DbMetaDataCollectionNames.cs
- MutexSecurity.cs
- DropDownButton.cs
- oledbmetadatacolumnnames.cs
- UpdateRecord.cs
- RotationValidation.cs
- Module.cs
- ResolveDuplexAsyncResult.cs
- ClientType.cs
- ExpressionConverter.cs
- EntityConnectionStringBuilder.cs
- DataBindingExpressionBuilder.cs
- FontFamily.cs
- ToolStripSettings.cs
- SoapBinding.cs
- TableLayoutColumnStyleCollection.cs
- _HeaderInfo.cs
- NativeMethods.cs
- Pen.cs
- TypeConvertions.cs
- TypeGeneratedEventArgs.cs
- DecimalAnimationUsingKeyFrames.cs
- CfgSemanticTag.cs
- ElementAction.cs
- MutexSecurity.cs
- SequenceNumber.cs
- PagedDataSource.cs
- NullReferenceException.cs
- ServiceModelEnhancedConfigurationElementCollection.cs
- XmlAnyElementAttributes.cs
- CodeTypeOfExpression.cs
- ConstNode.cs
- xamlnodes.cs
- DateTimeConverter2.cs
- BinaryMethodMessage.cs
- WindowsPen.cs
- AmbientEnvironment.cs
- WindowsListViewGroup.cs
- GenericIdentity.cs
- DetailsViewModeEventArgs.cs
- WebPartEditorApplyVerb.cs
- _ProxyChain.cs
- Effect.cs
- Transactions.cs
- DocumentSequence.cs
- DataServiceQueryProvider.cs
- coordinatorfactory.cs
- AmbientProperties.cs
- ComplexLine.cs
- WizardForm.cs
- MetadataArtifactLoader.cs
- XmlAnyAttributeAttribute.cs
- Claim.cs
- MemberDomainMap.cs
- EntityDataSourceChangedEventArgs.cs
- CapabilitiesPattern.cs
- FixedTextView.cs
- IpcServerChannel.cs
- FileEnumerator.cs
- ListViewSelectEventArgs.cs
- Quaternion.cs
- PromptBuilder.cs
- TextServicesProperty.cs
- BezierSegment.cs
- InstallerTypeAttribute.cs
- HttpProxyTransportBindingElement.cs