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
- XmlRawWriter.cs
- HttpListenerContext.cs
- WindowsPen.cs
- ImageInfo.cs
- PermissionSetTriple.cs
- InvalidFilterCriteriaException.cs
- PaintValueEventArgs.cs
- ViewStateModeByIdAttribute.cs
- ColorContextHelper.cs
- MailMessage.cs
- FileLoadException.cs
- CheckedListBox.cs
- SafeRightsManagementSessionHandle.cs
- ComponentCommands.cs
- XmlBinaryReader.cs
- codemethodreferenceexpression.cs
- initElementDictionary.cs
- DetailsViewDeleteEventArgs.cs
- AccessedThroughPropertyAttribute.cs
- MSAAEventDispatcher.cs
- EnglishPluralizationService.cs
- CategoryGridEntry.cs
- DataTemplateSelector.cs
- SchemaElementDecl.cs
- StringPropertyBuilder.cs
- EditorZoneDesigner.cs
- SamlAttribute.cs
- RectAnimation.cs
- DataGridParentRows.cs
- WindowsListViewGroupSubsetLink.cs
- ScrollProviderWrapper.cs
- SmtpTransport.cs
- WindowsTokenRoleProvider.cs
- RenderData.cs
- MgmtConfigurationRecord.cs
- QueryCursorEventArgs.cs
- EntityContainerEmitter.cs
- WebPartZoneDesigner.cs
- GridViewAutoFormat.cs
- XamlBrushSerializer.cs
- CellRelation.cs
- XslAstAnalyzer.cs
- RowTypePropertyElement.cs
- DrawingGroup.cs
- Underline.cs
- AuthorizationSection.cs
- FormViewActionList.cs
- ComplexBindingPropertiesAttribute.cs
- ZoneLinkButton.cs
- OdbcUtils.cs
- MD5CryptoServiceProvider.cs
- FixedSOMSemanticBox.cs
- COMException.cs
- LabelAutomationPeer.cs
- OutputCacheSettings.cs
- X509SubjectKeyIdentifierClause.cs
- EventSinkActivityDesigner.cs
- DocumentPageViewAutomationPeer.cs
- NameValueConfigurationElement.cs
- BuildManagerHost.cs
- Collection.cs
- Stack.cs
- XmlValidatingReaderImpl.cs
- SerTrace.cs
- ExpressionConverter.cs
- PropertyKey.cs
- XmlSchemaObjectCollection.cs
- Base64Encoding.cs
- DbModificationCommandTree.cs
- ObjectParameter.cs
- PolyLineSegmentFigureLogic.cs
- Font.cs
- UndoUnit.cs
- AsyncResult.cs
- PreviousTrackingServiceAttribute.cs
- RootCodeDomSerializer.cs
- DictionaryItemsCollection.cs
- DirectionalAction.cs
- ContentDisposition.cs
- documentsequencetextview.cs
- EdmFunction.cs
- Accessible.cs
- TreeView.cs
- CommandDevice.cs
- login.cs
- HuffModule.cs
- VolatileResourceManager.cs
- ToolBarButton.cs
- ResourceExpressionBuilder.cs
- DefaultPropertyAttribute.cs
- SID.cs
- AttachedAnnotation.cs
- Misc.cs
- MultiAsyncResult.cs
- DetailsViewPagerRow.cs
- ScriptingSectionGroup.cs
- LinqTreeNodeEvaluator.cs
- ListenerSessionConnection.cs
- LocationUpdates.cs
- DecoratedNameAttribute.cs