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
- InfocardChannelParameter.cs
- FilterInvalidBodyAccessException.cs
- XmlResolver.cs
- XslUrlEditor.cs
- MethodExecutor.cs
- TransformedBitmap.cs
- PackUriHelper.cs
- PaintEvent.cs
- DbConnectionFactory.cs
- SettingsProviderCollection.cs
- Translator.cs
- RegexCompiler.cs
- LineVisual.cs
- CharacterString.cs
- StringConverter.cs
- SizeChangedInfo.cs
- ContentPropertyAttribute.cs
- NamespaceEmitter.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- SQLCharsStorage.cs
- PropertyBuilder.cs
- FormsAuthenticationEventArgs.cs
- ToolStripControlHost.cs
- ModelItemExtensions.cs
- SqlFileStream.cs
- DataGridViewMethods.cs
- MemberAccessException.cs
- BuildManager.cs
- ManifestBasedResourceGroveler.cs
- safelinkcollection.cs
- TextTreePropertyUndoUnit.cs
- CodeCommentStatement.cs
- HTMLTextWriter.cs
- ConfigXmlSignificantWhitespace.cs
- CryptoApi.cs
- PriorityBinding.cs
- ZipFileInfo.cs
- ModelServiceImpl.cs
- SmiXetterAccessMap.cs
- XmlByteStreamReader.cs
- PersonalizationStateInfo.cs
- DataGridTextBox.cs
- DataSourceProvider.cs
- RedirectionProxy.cs
- Screen.cs
- SAPIEngineTypes.cs
- TextWriterEngine.cs
- HebrewCalendar.cs
- XmlWhitespace.cs
- GenericAuthenticationEventArgs.cs
- InfoCardServiceInstallComponent.cs
- OleDbTransaction.cs
- RootBrowserWindowAutomationPeer.cs
- PackageRelationshipSelector.cs
- GeneralTransform.cs
- EntityDataSourceView.cs
- WindowsPen.cs
- Error.cs
- ProcessProtocolHandler.cs
- SqlDataReader.cs
- AnnotationAuthorChangedEventArgs.cs
- JavaScriptObjectDeserializer.cs
- MimeObjectFactory.cs
- Preprocessor.cs
- DataBoundControlActionList.cs
- Pair.cs
- Underline.cs
- DisplayNameAttribute.cs
- MailHeaderInfo.cs
- SQLChars.cs
- BeginEvent.cs
- DataStreamFromComStream.cs
- VisualTarget.cs
- LoginUtil.cs
- PropertyConverter.cs
- ObjectTypeMapping.cs
- InstanceStoreQueryResult.cs
- TextRangeBase.cs
- HtmlInputCheckBox.cs
- SqlIdentifier.cs
- TextTreeRootNode.cs
- DSASignatureFormatter.cs
- MappingSource.cs
- TextServicesProperty.cs
- RegistryPermission.cs
- SerialPort.cs
- ProviderIncompatibleException.cs
- DataServiceSaveChangesEventArgs.cs
- LinkUtilities.cs
- AuthenticationException.cs
- StylusButtonEventArgs.cs
- BrowserDefinition.cs
- Bitmap.cs
- WaveHeader.cs
- MultiPageTextView.cs
- BaseAddressPrefixFilterElementCollection.cs
- SymDocumentType.cs
- Assembly.cs
- Transactions.cs
- NumericExpr.cs