Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Mail / ClosableStream.cs / 1 / ClosableStream.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net
{
using System;
using System.IO;
using System.Threading;
///
/// Provides a stream that notifies an event when the Close method
/// is called.
///
internal class ClosableStream : DelegatedStream
{
EventHandler onClose;
int closed;
internal ClosableStream(Stream stream, EventHandler onClose) : base(stream)
{
this.onClose = onClose;
}
public override void Close()
{
if (Interlocked.Increment(ref closed) == 1)
if (this.onClose != null)
this.onClose(this, new EventArgs());
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DecimalStorage.cs
- ResetableIterator.cs
- SoapExtensionTypeElement.cs
- WindowsProgressbar.cs
- BoundsDrawingContextWalker.cs
- UnauthorizedAccessException.cs
- XmlFormatExtensionPointAttribute.cs
- TopClause.cs
- CompressStream.cs
- FilterQueryOptionExpression.cs
- DesignerVerb.cs
- SpeechEvent.cs
- LinqExpressionNormalizer.cs
- PrintDialogException.cs
- AppLevelCompilationSectionCache.cs
- MemberJoinTreeNode.cs
- PointValueSerializer.cs
- BitmapEffectGeneralTransform.cs
- ObjectConverter.cs
- QueuePropertyVariants.cs
- CssTextWriter.cs
- LoginUtil.cs
- PointAnimationBase.cs
- webeventbuffer.cs
- TextTreeRootTextBlock.cs
- HtmlInputReset.cs
- XmlSerializableServices.cs
- ParameterRefs.cs
- adornercollection.cs
- FlowLayoutSettings.cs
- HttpListenerException.cs
- StringDictionary.cs
- PeerPresenceInfo.cs
- DataGridTableCollection.cs
- BamlTreeNode.cs
- HandlerElementCollection.cs
- SecurityKeyIdentifierClause.cs
- bindurihelper.cs
- MetadataPropertyCollection.cs
- TdsParameterSetter.cs
- XmlComment.cs
- Literal.cs
- XmlUtf8RawTextWriter.cs
- QilParameter.cs
- MonthChangedEventArgs.cs
- FusionWrap.cs
- CanonicalizationDriver.cs
- BinaryParser.cs
- CompilerState.cs
- TimelineCollection.cs
- CompositeKey.cs
- MSAAWinEventWrap.cs
- ListViewDeletedEventArgs.cs
- URLString.cs
- InputChannelBinder.cs
- FactoryId.cs
- RecognizerBase.cs
- XslTransformFileEditor.cs
- LocationSectionRecord.cs
- COM2ExtendedTypeConverter.cs
- StringAnimationUsingKeyFrames.cs
- LinkLabelLinkClickedEvent.cs
- path.cs
- ValidationService.cs
- MethodInfo.cs
- wmiprovider.cs
- CommandLibraryHelper.cs
- Point4DConverter.cs
- DataGridViewComboBoxCell.cs
- StylusCollection.cs
- LinearKeyFrames.cs
- CreateUserWizardDesigner.cs
- SignatureToken.cs
- InternalsVisibleToAttribute.cs
- HostSecurityManager.cs
- MapPathBasedVirtualPathProvider.cs
- ScriptIgnoreAttribute.cs
- selecteditemcollection.cs
- NativeMethods.cs
- InvalidDocumentContentsException.cs
- SplashScreen.cs
- XslAstAnalyzer.cs
- PictureBox.cs
- IconConverter.cs
- CircleHotSpot.cs
- SaveWorkflowCommand.cs
- XmlAggregates.cs
- DrawingDrawingContext.cs
- DataTableReaderListener.cs
- ResourcePropertyMemberCodeDomSerializer.cs
- SafeNativeMethods.cs
- ToolStripMenuItem.cs
- FileRecordSequenceCompletedAsyncResult.cs
- QueryContinueDragEventArgs.cs
- TextClipboardData.cs
- MessageDecoder.cs
- WebServiceParameterData.cs
- ItemCollection.cs
- ArrayTypeMismatchException.cs
- CheckBoxBaseAdapter.cs