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
- HtmlTableCell.cs
- GridViewRowCollection.cs
- unsafenativemethodsother.cs
- XmlSchemaInferenceException.cs
- TimeIntervalCollection.cs
- MouseEvent.cs
- CodePropertyReferenceExpression.cs
- OutKeywords.cs
- ControlFilterExpression.cs
- BooleanKeyFrameCollection.cs
- XmlWrappingWriter.cs
- MetafileHeader.cs
- ExtenderProviderService.cs
- RSAOAEPKeyExchangeDeformatter.cs
- MemberRelationshipService.cs
- EventMappingSettingsCollection.cs
- TextDecorationUnitValidation.cs
- WebConfigurationManager.cs
- VisualBrush.cs
- TemplateKeyConverter.cs
- DispatcherExceptionEventArgs.cs
- HostedImpersonationContext.cs
- Brush.cs
- WebPartEditorOkVerb.cs
- AuthStoreRoleProvider.cs
- ReadOnlyDataSource.cs
- XmlQueryStaticData.cs
- TransformerInfoCollection.cs
- ClientSettingsSection.cs
- ReadOnlyDictionary.cs
- BamlWriter.cs
- XpsFixedDocumentReaderWriter.cs
- ContentPlaceHolder.cs
- Faults.cs
- DependencyObjectPropertyDescriptor.cs
- CapabilitiesSection.cs
- StringInfo.cs
- PrePostDescendentsWalker.cs
- InternalCache.cs
- ExeContext.cs
- AssociationType.cs
- TextTreeRootNode.cs
- SystemWebSectionGroup.cs
- DesignerSerializerAttribute.cs
- HtmlTernaryTree.cs
- TextElementEnumerator.cs
- LoadGrammarCompletedEventArgs.cs
- XmlAttributeAttribute.cs
- NativeMethods.cs
- LinkDescriptor.cs
- LocalizationComments.cs
- IndependentAnimationStorage.cs
- SqlNodeAnnotations.cs
- LineServices.cs
- CompositeControl.cs
- XPathException.cs
- VarRefManager.cs
- PhysicalAddress.cs
- DifferencingCollection.cs
- LineGeometry.cs
- HideDisabledControlAdapter.cs
- NativeActivity.cs
- DataBindingHandlerAttribute.cs
- ConnectionPoint.cs
- PlanCompiler.cs
- FileIOPermission.cs
- TraceSwitch.cs
- FormViewInsertEventArgs.cs
- Statements.cs
- Tokenizer.cs
- InvokeHandlers.cs
- SqlCommandBuilder.cs
- WindowShowOrOpenTracker.cs
- AtomServiceDocumentSerializer.cs
- EpmContentSerializer.cs
- ToolStripItemBehavior.cs
- TextDecorationCollection.cs
- AnimationClock.cs
- ProcessHostMapPath.cs
- EventData.cs
- Viewport3DAutomationPeer.cs
- PropertyNames.cs
- PermissionSet.cs
- SubtreeProcessor.cs
- DataKey.cs
- WorkflowOperationErrorHandler.cs
- EventItfInfo.cs
- AvTrace.cs
- TemplateBindingExpressionConverter.cs
- PointLightBase.cs
- GeometryValueSerializer.cs
- WebPartCatalogCloseVerb.cs
- OAVariantLib.cs
- TimeSpanMinutesConverter.cs
- FactoryGenerator.cs
- EntityDataSourceWizardForm.cs
- ListViewGroupItemCollection.cs
- ComponentResourceKey.cs
- BufferBuilder.cs
- RoutedEventHandlerInfo.cs