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
- IODescriptionAttribute.cs
- XmlAtomicValue.cs
- CLSCompliantAttribute.cs
- QuaternionAnimationUsingKeyFrames.cs
- GcHandle.cs
- HttpListenerResponse.cs
- HtmlTextViewAdapter.cs
- XmlILIndex.cs
- _DisconnectOverlappedAsyncResult.cs
- UpdateExpressionVisitor.cs
- LightweightCodeGenerator.cs
- OAVariantLib.cs
- ConsoleTraceListener.cs
- DBCommandBuilder.cs
- ScrollBar.cs
- ReferentialConstraint.cs
- XmlSchemaAll.cs
- SqlDataSource.cs
- ReturnValue.cs
- DoubleAnimationBase.cs
- PolicyLevel.cs
- RegisteredDisposeScript.cs
- SignalGate.cs
- XPathMultyIterator.cs
- XmlTextWriter.cs
- counter.cs
- UdpMessageProperty.cs
- ConstructorExpr.cs
- RegisteredArrayDeclaration.cs
- CommandID.cs
- RelationshipConverter.cs
- BitArray.cs
- InvalidPipelineStoreException.cs
- NavigationPropertyEmitter.cs
- TimeSpanConverter.cs
- CodeGeneratorOptions.cs
- OneOfTypeConst.cs
- DetailsViewPageEventArgs.cs
- SchemaImporter.cs
- DeclaredTypeElement.cs
- NullableBoolConverter.cs
- HtmlUtf8RawTextWriter.cs
- Boolean.cs
- PageThemeParser.cs
- JulianCalendar.cs
- DataGridDetailsPresenter.cs
- StyleSelector.cs
- DbExpressionBuilder.cs
- StructuredTypeEmitter.cs
- FutureFactory.cs
- CompositeScriptReferenceEventArgs.cs
- SingleAnimation.cs
- FrameworkPropertyMetadata.cs
- ScriptResourceHandler.cs
- ParameterElementCollection.cs
- LineServicesCallbacks.cs
- OracleCommandSet.cs
- SHA256.cs
- FilteredXmlReader.cs
- ObjectHandle.cs
- BlobPersonalizationState.cs
- EmitterCache.cs
- ReturnType.cs
- MethodRental.cs
- LocatorBase.cs
- DrawListViewSubItemEventArgs.cs
- UserControl.cs
- StaticFileHandler.cs
- ExportOptions.cs
- PictureBoxDesigner.cs
- AdjustableArrowCap.cs
- CollectionConverter.cs
- NumberFunctions.cs
- XomlCompiler.cs
- DataGridViewCellStyleChangedEventArgs.cs
- _ProxyChain.cs
- SocketInformation.cs
- Utils.cs
- RectangleConverter.cs
- ColumnHeaderCollectionEditor.cs
- CodeDOMUtility.cs
- DataGridViewCellMouseEventArgs.cs
- SessionState.cs
- Permission.cs
- EventRecord.cs
- DocumentApplication.cs
- QuerySettings.cs
- MultiDataTrigger.cs
- DomainConstraint.cs
- RequestCacheEntry.cs
- FixedPageProcessor.cs
- TraceHelpers.cs
- SqlUtil.cs
- FrameworkElementAutomationPeer.cs
- Message.cs
- TextSpan.cs
- TypeHelper.cs
- TextEndOfLine.cs
- QilTernary.cs
- SystemIcmpV4Statistics.cs