Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / IO / MemoryMappedFiles / MemoryMappedViewAccessor.cs / 1305376 / MemoryMappedViewAccessor.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: MemoryMappedViewAccessor ** ** Purpose: View accessor for managed MemoryMappedFiles ** ** Date: February 7, 2007 ** ===========================================================*/ using System; using System.Diagnostics; using System.Security.Permissions; using Microsoft.Win32.SafeHandles; namespace System.IO.MemoryMappedFiles { public sealed class MemoryMappedViewAccessor : UnmanagedMemoryAccessor { private MemoryMappedView m_view; //// [System.Security.SecurityCritical] internal MemoryMappedViewAccessor(MemoryMappedView view) { Debug.Assert(view != null, "view is null"); m_view = view; Initialize(m_view.ViewHandle, m_view.PointerOffset, m_view.Size, MemoryMappedFile.GetFileAccess(m_view.Access)); } public SafeMemoryMappedViewHandle SafeMemoryMappedViewHandle { //// // // // [System.Security.SecurityCritical] [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] get { return m_view != null ? m_view.ViewHandle : null; } } //// // [System.Security.SecurityCritical] protected override void Dispose(bool disposing) { try { // Explicitly flush the changes. The OS will do this for us anyway, but not until after the // MemoryMappedFile object itself is closed. if (disposing && m_view != null && !m_view.IsClosed) { Flush(); } } finally { try { if (m_view != null) { m_view.Dispose(); } } finally { base.Dispose(disposing); } } } // Flushes the changes such that they are in [....] with the FileStream bits (ones obtained // with the win32 ReadFile and WriteFile functions). Need to call FileStream's Flush to // flush to the disk. // NOTE: This will flush all bytes before and after the view up until an offset that is a // multiple of SystemPageSize. //// // [System.Security.SecurityCritical] public void Flush() { if (!IsOpen) { throw new ObjectDisposedException("MemoryMappedViewAccessor", SR.GetString(SR.ObjectDisposed_ViewAccessorClosed)); } unsafe { if (m_view != null) { m_view.Flush((IntPtr)Capacity); } } } } } // 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
- DynamicActionMessageFilter.cs
- SAPICategories.cs
- OperationInvokerBehavior.cs
- XmlLanguageConverter.cs
- FileChangesMonitor.cs
- XmlSchemaFacet.cs
- VisualCollection.cs
- ChtmlImageAdapter.cs
- Point.cs
- DynamicFilterExpression.cs
- SchemaTableOptionalColumn.cs
- ThreadAttributes.cs
- ParseChildrenAsPropertiesAttribute.cs
- UnsafeNativeMethods.cs
- WebPartVerb.cs
- SqlSupersetValidator.cs
- HttpContextServiceHost.cs
- SoapReflector.cs
- FormCollection.cs
- DataGridViewCellValidatingEventArgs.cs
- TreeViewAutomationPeer.cs
- ILGenerator.cs
- HttpVersion.cs
- Int32Animation.cs
- MarshalDirectiveException.cs
- Atom10ItemFormatter.cs
- HttpContextServiceHost.cs
- NativeMethods.cs
- DockPanel.cs
- StylusEditingBehavior.cs
- HelpKeywordAttribute.cs
- GeometryGroup.cs
- UInt16Storage.cs
- SiteMembershipCondition.cs
- SecurityStandardsManager.cs
- HashHelpers.cs
- SqlExpander.cs
- BinaryKeyIdentifierClause.cs
- OleDbPropertySetGuid.cs
- GraphicsPath.cs
- DelegatedStream.cs
- Expressions.cs
- ChangePassword.cs
- SqlProfileProvider.cs
- Form.cs
- MatchingStyle.cs
- SByteStorage.cs
- ViewPort3D.cs
- Int32Animation.cs
- ExpandCollapseProviderWrapper.cs
- PointConverter.cs
- MenuEventArgs.cs
- PrintingPermission.cs
- ZipPackagePart.cs
- HttpBufferlessInputStream.cs
- _emptywebproxy.cs
- AssociatedControlConverter.cs
- EventSetter.cs
- UriScheme.cs
- PagesSection.cs
- ProfileProvider.cs
- ControlTemplate.cs
- AnnotationHelper.cs
- XmlUrlResolver.cs
- SocketStream.cs
- KeyTimeConverter.cs
- Matrix3DConverter.cs
- ArgumentOutOfRangeException.cs
- TraceHandlerErrorFormatter.cs
- Decorator.cs
- JsonUriDataContract.cs
- ParseNumbers.cs
- HTTP_SERVICE_CONFIG_URLACL_KEY.cs
- BitmapMetadataEnumerator.cs
- DiscoveryReference.cs
- MSAANativeProvider.cs
- HttpPostProtocolImporter.cs
- SqlTypeConverter.cs
- FamilyCollection.cs
- SingleAnimationUsingKeyFrames.cs
- DataSourceConverter.cs
- UpdateCommand.cs
- ObjectConverter.cs
- ProjectionCamera.cs
- EventSourceCreationData.cs
- CopyAttributesAction.cs
- mediaeventshelper.cs
- EncodingTable.cs
- XPathScanner.cs
- IndexedEnumerable.cs
- ApplicationTrust.cs
- FontUnit.cs
- JavaScriptSerializer.cs
- ExeContext.cs
- SettingsBindableAttribute.cs
- Empty.cs
- ScrollViewerAutomationPeer.cs
- ErrorWebPart.cs
- TextServicesContext.cs
- ObjectStorage.cs