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
- Context.cs
- ObjectView.cs
- InstanceKeyCollisionException.cs
- OdbcEnvironmentHandle.cs
- IntSecurity.cs
- HiddenFieldPageStatePersister.cs
- MsmqIntegrationBindingElement.cs
- DbProviderFactory.cs
- DefaultSection.cs
- CalendarDateRange.cs
- _SslState.cs
- TabPage.cs
- XmlNavigatorFilter.cs
- thaishape.cs
- SystemTcpConnection.cs
- Rule.cs
- RoleManagerEventArgs.cs
- DynamicDiscoveryDocument.cs
- ClickablePoint.cs
- XmlSchemaCollection.cs
- OutKeywords.cs
- GroupAggregateExpr.cs
- CachedPathData.cs
- recordstatescratchpad.cs
- WinFormsSpinner.cs
- GestureRecognitionResult.cs
- HttpListenerException.cs
- SizeAnimationUsingKeyFrames.cs
- GenericPrincipal.cs
- ListItemCollection.cs
- ReflectionUtil.cs
- TextParagraphView.cs
- LayoutDump.cs
- DecoderBestFitFallback.cs
- QilDataSource.cs
- EntityDesignerUtils.cs
- Attribute.cs
- URLIdentityPermission.cs
- TextTrailingCharacterEllipsis.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- SqlReferenceCollection.cs
- BamlResourceDeserializer.cs
- Point3DAnimationUsingKeyFrames.cs
- assemblycache.cs
- SafeFileMappingHandle.cs
- NetworkInformationPermission.cs
- HostExecutionContextManager.cs
- ReadOnlyMetadataCollection.cs
- SetterBaseCollection.cs
- IgnoreDeviceFilterElementCollection.cs
- ContextMenuService.cs
- ControlBuilder.cs
- DataSourceCacheDurationConverter.cs
- SignHashRequest.cs
- SmtpMail.cs
- SectionInput.cs
- StrokeNodeData.cs
- UnsafeNativeMethods.cs
- EventWaitHandle.cs
- _ListenerRequestStream.cs
- ViewGenerator.cs
- ParameterToken.cs
- WindowsListView.cs
- EpmCustomContentDeSerializer.cs
- SqlParameterCollection.cs
- ObjectDataSourceEventArgs.cs
- HandledMouseEvent.cs
- DesignDataSource.cs
- ApplyHostConfigurationBehavior.cs
- DataServiceQueryOfT.cs
- ReflectEventDescriptor.cs
- AutoResetEvent.cs
- PeerNameRegistration.cs
- StyleCollectionEditor.cs
- VectorCollectionValueSerializer.cs
- RichTextBox.cs
- FixedPageAutomationPeer.cs
- CachedCompositeFamily.cs
- WorkflowElementDialog.cs
- ParameterBuilder.cs
- SqlSupersetValidator.cs
- TiffBitmapEncoder.cs
- ToolTip.cs
- CallTemplateAction.cs
- BindingSource.cs
- CompModSwitches.cs
- Literal.cs
- CroppedBitmap.cs
- GatewayIPAddressInformationCollection.cs
- DecimalAnimation.cs
- ReplacementText.cs
- ToolStripComboBox.cs
- DesignerGenericWebPart.cs
- Overlapped.cs
- DisposableCollectionWrapper.cs
- ServicePoint.cs
- RectValueSerializer.cs
- CodeCastExpression.cs
- LiteralControl.cs
- DataGridViewComboBoxEditingControl.cs