Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Log / System / IO / Log / AppendHelper.cs / 1 / 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. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListViewItem.cs
- CompiledRegexRunnerFactory.cs
- ConsoleTraceListener.cs
- XsdDataContractExporter.cs
- ObjectAnimationUsingKeyFrames.cs
- ApplicationInfo.cs
- RowType.cs
- ExchangeUtilities.cs
- documentsequencetextview.cs
- DrawingContext.cs
- _ChunkParse.cs
- WindowsListViewItemCheckBox.cs
- XhtmlBasicCommandAdapter.cs
- path.cs
- TabletCollection.cs
- AndCondition.cs
- UInt16Storage.cs
- ImageSourceValueSerializer.cs
- NativeMethodsCLR.cs
- PreparingEnlistment.cs
- ExceptionUtil.cs
- DebuggerAttributes.cs
- WebPartEditorCancelVerb.cs
- VectorKeyFrameCollection.cs
- Assert.cs
- MD5Cng.cs
- SmtpReplyReaderFactory.cs
- AutomationPatternInfo.cs
- FrameworkTemplate.cs
- WebServiceHandlerFactory.cs
- ComboBoxRenderer.cs
- GenericTypeParameterBuilder.cs
- ZipIOCentralDirectoryFileHeader.cs
- HTTPRemotingHandler.cs
- ComplexTypeEmitter.cs
- Bold.cs
- HtmlHead.cs
- DataColumnPropertyDescriptor.cs
- ResolvedKeyFrameEntry.cs
- DesignerForm.cs
- Image.cs
- RegionInfo.cs
- DeleteHelper.cs
- SecurityPermission.cs
- ViewCellSlot.cs
- QueryGeneratorBase.cs
- DataServiceHostFactory.cs
- ConfigurationConverterBase.cs
- ToolStripPanel.cs
- HasCopySemanticsAttribute.cs
- WebPartZoneCollection.cs
- ResourceContainerWrapper.cs
- SettingsBase.cs
- ProxyWebPartManager.cs
- DataGridTableCollection.cs
- Visual3D.cs
- RadioButtonAutomationPeer.cs
- EmbeddedMailObjectsCollection.cs
- BooleanConverter.cs
- OleDbCommandBuilder.cs
- CodeEventReferenceExpression.cs
- CustomErrorsSection.cs
- ChangeProcessor.cs
- DataGridViewCellEventArgs.cs
- OneOfTypeConst.cs
- StringInfo.cs
- ComponentDesigner.cs
- CompilationLock.cs
- PageBreakRecord.cs
- StagingAreaInputItem.cs
- CalendarButtonAutomationPeer.cs
- SelectionItemPattern.cs
- XmlILIndex.cs
- ObjectNotFoundException.cs
- DbRetry.cs
- ValueTypeFixupInfo.cs
- GlyphingCache.cs
- TextPattern.cs
- SQLRoleProvider.cs
- ToolStripItem.cs
- XPathMultyIterator.cs
- FindResponse.cs
- Keyboard.cs
- RawKeyboardInputReport.cs
- StubHelpers.cs
- ManagementClass.cs
- SingleTagSectionHandler.cs
- ModifierKeysValueSerializer.cs
- HiddenFieldPageStatePersister.cs
- PropertyGridView.cs
- ComponentResourceManager.cs
- PrimaryKeyTypeConverter.cs
- UserMapPath.cs
- BlurEffect.cs
- TwoPhaseCommit.cs
- Debug.cs
- MenuItemBindingCollection.cs
- SchemaImporterExtension.cs
- WebEventTraceProvider.cs
- CircleHotSpot.cs