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
- NumberFunctions.cs
- WinInetCache.cs
- DataReceivedEventArgs.cs
- FunctionParameter.cs
- brushes.cs
- SmtpReplyReader.cs
- EncryptedXml.cs
- ConsumerConnectionPoint.cs
- MimeFormatExtensions.cs
- HelpInfo.cs
- VisualStates.cs
- SoapDocumentServiceAttribute.cs
- CalendarDayButton.cs
- FacetChecker.cs
- DeferredSelectedIndexReference.cs
- Model3DCollection.cs
- PerfService.cs
- SecurityTokenSpecification.cs
- RequestSecurityTokenForRemoteTokenFactory.cs
- FillErrorEventArgs.cs
- Point3D.cs
- KnownColorTable.cs
- LayoutEvent.cs
- ImageMapEventArgs.cs
- ParseHttpDate.cs
- UpDownEvent.cs
- ExtractedStateEntry.cs
- MimeMapping.cs
- Logging.cs
- XmlElementCollection.cs
- ObjectListShowCommandsEventArgs.cs
- XmlSchema.cs
- TextFormatterContext.cs
- Console.cs
- IInstanceTable.cs
- Activity.cs
- ObservableCollection.cs
- UnsafeNativeMethods.cs
- CharacterMetricsDictionary.cs
- UnauthorizedWebPart.cs
- PartialArray.cs
- SingleAnimationUsingKeyFrames.cs
- FtpWebRequest.cs
- ListViewCancelEventArgs.cs
- XmlCodeExporter.cs
- Group.cs
- RemotingServices.cs
- TreeNodeConverter.cs
- StrokeDescriptor.cs
- Rotation3DAnimationBase.cs
- TimeStampChecker.cs
- EventLogger.cs
- FontNamesConverter.cs
- HtmlContainerControl.cs
- TableLayoutPanel.cs
- AxisAngleRotation3D.cs
- TableLayoutPanelBehavior.cs
- DTCTransactionManager.cs
- BitmapEffectGeneralTransform.cs
- ControlType.cs
- ILGenerator.cs
- DataGridViewRowConverter.cs
- Context.cs
- ObjectViewListener.cs
- LayoutInformation.cs
- NeutralResourcesLanguageAttribute.cs
- EditorZone.cs
- DbSetClause.cs
- AccessViolationException.cs
- MasterPageBuildProvider.cs
- Odbc32.cs
- HtmlInputButton.cs
- DatePicker.cs
- LineServicesCallbacks.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- Accessible.cs
- WriteTimeStream.cs
- VectorCollectionValueSerializer.cs
- WrapperEqualityComparer.cs
- InputLanguageProfileNotifySink.cs
- HandleScope.cs
- NetworkInformationException.cs
- XPathAxisIterator.cs
- BufferedStream.cs
- ObjectDataSource.cs
- JavaScriptSerializer.cs
- UMPAttributes.cs
- ComponentResourceKeyConverter.cs
- UniqueIdentifierService.cs
- ConditionalAttribute.cs
- FactoryId.cs
- ConsoleTraceListener.cs
- BitmapCodecInfo.cs
- ToolStripPanelRenderEventArgs.cs
- SessionIDManager.cs
- BackgroundWorker.cs
- ProcessModule.cs
- ContextMenuStripGroupCollection.cs
- MouseWheelEventArgs.cs
- TextServicesProperty.cs