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
- TimeSpanMinutesConverter.cs
- IndexedString.cs
- ConditionedDesigner.cs
- FontConverter.cs
- DefaultEventAttribute.cs
- CrossContextChannel.cs
- ICspAsymmetricAlgorithm.cs
- DataRowComparer.cs
- HandledEventArgs.cs
- ConnectionManagementElementCollection.cs
- PrefixQName.cs
- assertwrapper.cs
- SmtpReplyReaderFactory.cs
- MenuItemBindingCollection.cs
- StrokeFIndices.cs
- AdjustableArrowCap.cs
- ErrorProvider.cs
- AsymmetricKeyExchangeFormatter.cs
- ImageCodecInfoPrivate.cs
- ObjectMemberMapping.cs
- WebPartCloseVerb.cs
- BorderGapMaskConverter.cs
- Cursor.cs
- XmlSchemaRedefine.cs
- PolicyFactory.cs
- TemplatingOptionsDialog.cs
- PackagePart.cs
- DataRowCollection.cs
- Point3DCollectionValueSerializer.cs
- FileCodeGroup.cs
- CookieProtection.cs
- XPathSelfQuery.cs
- ExpressionBuilder.cs
- ColorContextHelper.cs
- StringComparer.cs
- BasicViewGenerator.cs
- SqlMethods.cs
- MethodImplAttribute.cs
- CurrentTimeZone.cs
- CodeVariableReferenceExpression.cs
- DtdParser.cs
- WebConfigurationManager.cs
- OrderByExpression.cs
- RegexMatchCollection.cs
- WebServicesDescriptionAttribute.cs
- StorageAssociationTypeMapping.cs
- ToolStripPanelRow.cs
- ReferentialConstraintRoleElement.cs
- ChangeProcessor.cs
- SoapAttributeOverrides.cs
- WebServiceData.cs
- _ConnectOverlappedAsyncResult.cs
- SafeNativeMethods.cs
- SQLConvert.cs
- _ListenerRequestStream.cs
- AuthenticatedStream.cs
- ColorMatrix.cs
- DefaultMemberAttribute.cs
- CriticalFinalizerObject.cs
- SettingsContext.cs
- Convert.cs
- connectionpool.cs
- HtmlGenericControl.cs
- SharedDp.cs
- Brush.cs
- DataGridViewToolTip.cs
- ItemCollection.cs
- AssemblyNameProxy.cs
- WindowsHyperlink.cs
- Pen.cs
- MailBnfHelper.cs
- PersonalizationAdministration.cs
- AmbientLight.cs
- FlowDocumentReaderAutomationPeer.cs
- EnumerableCollectionView.cs
- _PooledStream.cs
- RectValueSerializer.cs
- RtfToXamlLexer.cs
- MarshalByRefObject.cs
- Maps.cs
- DataGridTable.cs
- ScriptingWebServicesSectionGroup.cs
- Vector3DValueSerializer.cs
- WebServiceClientProxyGenerator.cs
- ServiceMemoryGates.cs
- MsmqBindingBase.cs
- DynamicResourceExtensionConverter.cs
- HighContrastHelper.cs
- Calendar.cs
- BitmapEffectDrawingContent.cs
- XmlAnyElementAttributes.cs
- Expressions.cs
- TemplateColumn.cs
- _DomainName.cs
- TextMessageEncoder.cs
- Column.cs
- RectangleHotSpot.cs
- AuthenticationModuleElementCollection.cs
- DataBoundControlHelper.cs
- ElementAction.cs