Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Mail / ClosableStream.cs / 1305376 / 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());
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// 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());
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CancellableEnumerable.cs
- RenderOptions.cs
- UnmanagedMemoryStreamWrapper.cs
- SmiMetaData.cs
- ISAPIRuntime.cs
- HostedBindingBehavior.cs
- sqlser.cs
- ColorMatrix.cs
- HttpListenerRequest.cs
- ContentDefinition.cs
- Cloud.cs
- PlatformCulture.cs
- RegistryExceptionHelper.cs
- MemberDomainMap.cs
- HttpHandlersSection.cs
- DocumentOrderComparer.cs
- DataListItemCollection.cs
- ModelTypeConverter.cs
- MouseDevice.cs
- RuleCache.cs
- ModuleElement.cs
- PrintDocument.cs
- ActivationArguments.cs
- AmbiguousMatchException.cs
- KeyPullup.cs
- DoubleAnimationClockResource.cs
- RoutedEventArgs.cs
- ObjectDataSource.cs
- BinaryUtilClasses.cs
- StrokeNodeOperations2.cs
- Page.cs
- InvalidDataContractException.cs
- XmlSchemaException.cs
- SQLBoolean.cs
- XpsS0ValidatingLoader.cs
- XPathNodePointer.cs
- DataContractSerializerSection.cs
- TableSectionStyle.cs
- SoapDocumentMethodAttribute.cs
- MimeParameters.cs
- PathSegmentCollection.cs
- CqlIdentifiers.cs
- DynamicQueryableWrapper.cs
- ImageCodecInfoPrivate.cs
- ScrollBarRenderer.cs
- XmlLanguageConverter.cs
- Line.cs
- IteratorFilter.cs
- SpnEndpointIdentityExtension.cs
- NavigationService.cs
- TimeManager.cs
- AudioStateChangedEventArgs.cs
- Transform.cs
- DataStorage.cs
- EntityClassGenerator.cs
- ResourceReader.cs
- PolicyManager.cs
- MenuItemStyleCollection.cs
- PeerPresenceInfo.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- DictionaryEntry.cs
- DataGridViewLayoutData.cs
- ObjectDataSourceDisposingEventArgs.cs
- VScrollBar.cs
- UnsafeNativeMethods.cs
- ObjectComplexPropertyMapping.cs
- CodeChecksumPragma.cs
- SqlServer2KCompatibilityAnnotation.cs
- _ProxyChain.cs
- LeafCellTreeNode.cs
- ProviderCommandInfoUtils.cs
- CodeCatchClause.cs
- StoreContentChangedEventArgs.cs
- TrackingAnnotationCollection.cs
- NotifyIcon.cs
- ComContractElementCollection.cs
- DataGridViewCheckBoxCell.cs
- BuildManager.cs
- LinkedResource.cs
- ResourceDictionaryCollection.cs
- HttpVersion.cs
- CompatibleComparer.cs
- Permission.cs
- LifetimeServices.cs
- BackEase.cs
- NotFiniteNumberException.cs
- HtmlInputImage.cs
- BaseComponentEditor.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- AppDomain.cs
- ListViewItemEventArgs.cs
- BrowsableAttribute.cs
- TemplateParser.cs
- DBConcurrencyException.cs
- FormsAuthenticationUser.cs
- Tracer.cs
- CannotUnloadAppDomainException.cs
- ProtectedConfigurationSection.cs
- MetadataPropertyCollection.cs
- EntityContainer.cs