Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Log / System / IO / Log / AppendHelper.cs / 1305376 / AppendHelper.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace System.IO.Log { class AppendHelper : IDisposable { SequenceNumber prev; SequenceNumber next; FileLogRecordHeader header; UnmanagedBlob[] blobs; GCHandle[] handles; public AppendHelper(IList> data, SequenceNumber prev, SequenceNumber next, bool restartArea) { this.prev = prev; this.next = next; this.header = new FileLogRecordHeader(null); this.header.IsRestartArea = restartArea; this.header.PreviousLsn = prev; this.header.NextUndoLsn = next; this.blobs = new UnmanagedBlob[data.Count + 1]; this.handles = new GCHandle[data.Count + 1]; try { this.handles[0] = GCHandle.Alloc(header.Bits, GCHandleType.Pinned); this.blobs[0].cbSize = (uint)FileLogRecordHeader.Size; this.blobs[0].pBlobData = Marshal.UnsafeAddrOfPinnedArrayElement(header.Bits, 0); for (int i = 0; i < data.Count; i++) { handles[i + 1] = GCHandle.Alloc(data[i].Array, GCHandleType.Pinned); blobs[i + 1].cbSize = (uint)data[i].Count; blobs[i + 1].pBlobData = Marshal.UnsafeAddrOfPinnedArrayElement(data[i].Array, data[i].Offset); } } catch { Dispose(); throw; } } public UnmanagedBlob[] Blobs { get { return this.blobs; } } // Caller should always call Dispose. Finalizer not implemented. public void Dispose() { try { lock(this) { for (int i = 0; i < handles.Length; i++) { if (handles[i].IsAllocated) handles[i].Free(); } } } catch(InvalidOperationException exception) { // This indicates something is broken in IO.Log's memory management, // so it's not safe to continue executing DiagnosticUtility.InvokeFinalHandler(exception); } } } } // 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
- WebRequestModulesSection.cs
- WebServiceBindingAttribute.cs
- ExceptionUtil.cs
- NavigationHelper.cs
- PackageDigitalSignature.cs
- ListCollectionView.cs
- WindowsProgressbar.cs
- FieldBuilder.cs
- ProfilePropertyNameValidator.cs
- panel.cs
- InfoCardKeyedHashAlgorithm.cs
- Missing.cs
- AppDomainProtocolHandler.cs
- UInt64Converter.cs
- NameValueSectionHandler.cs
- ELinqQueryState.cs
- Int16Animation.cs
- _AutoWebProxyScriptEngine.cs
- KnownIds.cs
- XmlILAnnotation.cs
- MetadataItem_Static.cs
- SamlConstants.cs
- WebPartCloseVerb.cs
- SoapSchemaMember.cs
- ThreadExceptionEvent.cs
- TableLayoutStyleCollection.cs
- PropertySourceInfo.cs
- VerificationException.cs
- SemaphoreFullException.cs
- SqlDependency.cs
- LocatorManager.cs
- versioninfo.cs
- ReadOnlyDataSource.cs
- TransactionManager.cs
- SQLCharsStorage.cs
- Camera.cs
- ArrayItemValue.cs
- BitmapMetadataEnumerator.cs
- BlurBitmapEffect.cs
- MailWriter.cs
- Win32MouseDevice.cs
- UrlAuthorizationModule.cs
- UTF7Encoding.cs
- TextServicesDisplayAttribute.cs
- XmlIlTypeHelper.cs
- SoundPlayer.cs
- HtmlInputFile.cs
- DesignerDataColumn.cs
- WebPartChrome.cs
- DbgUtil.cs
- MutableAssemblyCacheEntry.cs
- WebPartEditVerb.cs
- AccessorTable.cs
- ArithmeticException.cs
- XmlILOptimizerVisitor.cs
- CornerRadiusConverter.cs
- WebHeaderCollection.cs
- ControlAdapter.cs
- HttpVersion.cs
- EntryWrittenEventArgs.cs
- HtmlShimManager.cs
- BaseParser.cs
- ClientType.cs
- DBDataPermissionAttribute.cs
- ConfigurationElementCollection.cs
- ProofTokenCryptoHandle.cs
- Application.cs
- PasswordDeriveBytes.cs
- listitem.cs
- Accessors.cs
- ButtonPopupAdapter.cs
- Label.cs
- ContainerActivationHelper.cs
- CacheEntry.cs
- HashLookup.cs
- SqlMethodCallConverter.cs
- ClientProxyGenerator.cs
- CanExecuteRoutedEventArgs.cs
- ExpressionPrefixAttribute.cs
- TypeTypeConverter.cs
- EdmEntityTypeAttribute.cs
- PerformanceCounter.cs
- CheckBoxDesigner.cs
- BlurEffect.cs
- unsafenativemethodstextservices.cs
- CompilationUtil.cs
- FilteredAttributeCollection.cs
- SyndicationSerializer.cs
- ToolStripItemEventArgs.cs
- LogEntry.cs
- PackageFilter.cs
- TextReader.cs
- UnsafeNativeMethods.cs
- StyleHelper.cs
- HtmlTableCell.cs
- XmlComment.cs
- safemediahandle.cs
- XmlSchemaInferenceException.cs
- PerformanceCounterNameAttribute.cs
- XmlLoader.cs