Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Log / System / IO / Log / LogFlushAsyncResult.cs / 1305376 / LogFlushAsyncResult.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IO.Log { using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security.Permissions; using System.Threading; using Microsoft.Win32.SafeHandles; sealed class LogFlushAsyncResult : OverlappedAsyncResult { LogRecordSequence recordSequence; ulong sequenceNumber; object boxedResultLsn; GCHandle pinnedResultLsn; internal LogFlushAsyncResult(LogRecordSequence recordSequence, AsyncCallback callback, object state) : base(callback, state) { this.recordSequence = recordSequence; } //=========================================================== // Parameters //=========================================================== internal ulong SequenceNumber { /* get { return this.sequenceNumber; } */ set { this.sequenceNumber = value; } } //============================================================ // Result //=========================================================== internal ulong ResultLsn { get { return (ulong)this.boxedResultLsn; } } internal void Start() { try { ulong resultLsn = 0; this.boxedResultLsn = (object)(resultLsn); this.pinnedResultLsn = GCHandle.Alloc(this.boxedResultLsn, GCHandleType.Pinned); Pack(this.boxedResultLsn); uint errorCode; unsafe { errorCode = UnsafeNativeMethods.FlushLogToLsnAsync( this.recordSequence.MarshalContext, ref this.sequenceNumber, this.pinnedResultLsn.AddrOfPinnedObject(), this.NativeOverlapped); } if (errorCode != Error.ERROR_IO_PENDING) { // We don't need to call Free() in a finally block, // because any exception will failfast the process Free(); this.pinnedResultLsn.Free(); if (errorCode == Error.ERROR_SUCCESS) { Complete(true, null); } else { Complete( true, UnsafeNativeMethods.FlushLogToLsnFilter(errorCode)); } } } #pragma warning suppress 56500 // We will be terminating the process with any exception in this call catch(Exception e) { // The code in the try block should not throw any exceptions. // If an exception is caught here, IO.Log may be in an unknown state. // We prefer to failfast instead of risking the possibility of log corruption. // Any client code using IO.Log must have a recovery model that can deal // with appdomain and process failures. DiagnosticUtility.InvokeFinalHandler(e); } } internal override void IOCompleted(uint errorCode) { this.pinnedResultLsn.Free(); if (errorCode == Error.ERROR_SUCCESS) { Complete(false, null); } else { Complete(false, UnsafeNativeMethods.FlushLogToLsnFilter(errorCode)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IO.Log { using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security.Permissions; using System.Threading; using Microsoft.Win32.SafeHandles; sealed class LogFlushAsyncResult : OverlappedAsyncResult { LogRecordSequence recordSequence; ulong sequenceNumber; object boxedResultLsn; GCHandle pinnedResultLsn; internal LogFlushAsyncResult(LogRecordSequence recordSequence, AsyncCallback callback, object state) : base(callback, state) { this.recordSequence = recordSequence; } //=========================================================== // Parameters //=========================================================== internal ulong SequenceNumber { /* get { return this.sequenceNumber; } */ set { this.sequenceNumber = value; } } //============================================================ // Result //=========================================================== internal ulong ResultLsn { get { return (ulong)this.boxedResultLsn; } } internal void Start() { try { ulong resultLsn = 0; this.boxedResultLsn = (object)(resultLsn); this.pinnedResultLsn = GCHandle.Alloc(this.boxedResultLsn, GCHandleType.Pinned); Pack(this.boxedResultLsn); uint errorCode; unsafe { errorCode = UnsafeNativeMethods.FlushLogToLsnAsync( this.recordSequence.MarshalContext, ref this.sequenceNumber, this.pinnedResultLsn.AddrOfPinnedObject(), this.NativeOverlapped); } if (errorCode != Error.ERROR_IO_PENDING) { // We don't need to call Free() in a finally block, // because any exception will failfast the process Free(); this.pinnedResultLsn.Free(); if (errorCode == Error.ERROR_SUCCESS) { Complete(true, null); } else { Complete( true, UnsafeNativeMethods.FlushLogToLsnFilter(errorCode)); } } } #pragma warning suppress 56500 // We will be terminating the process with any exception in this call catch(Exception e) { // The code in the try block should not throw any exceptions. // If an exception is caught here, IO.Log may be in an unknown state. // We prefer to failfast instead of risking the possibility of log corruption. // Any client code using IO.Log must have a recovery model that can deal // with appdomain and process failures. DiagnosticUtility.InvokeFinalHandler(e); } } internal override void IOCompleted(uint errorCode) { this.pinnedResultLsn.Free(); if (errorCode == Error.ERROR_SUCCESS) { Complete(false, null); } else { Complete(false, UnsafeNativeMethods.FlushLogToLsnFilter(errorCode)); } } } } // 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
- SecurityTokenValidationException.cs
- EvidenceTypeDescriptor.cs
- SafePEFileHandle.cs
- Convert.cs
- RadioButtonRenderer.cs
- SafeWaitHandle.cs
- PeerNode.cs
- _AutoWebProxyScriptWrapper.cs
- XmlILModule.cs
- PrintPreviewGraphics.cs
- TypeUnloadedException.cs
- CollectionChangeEventArgs.cs
- BinaryUtilClasses.cs
- BasicKeyConstraint.cs
- TypeExtensionConverter.cs
- XsltLoader.cs
- CodeObjectCreateExpression.cs
- GeometryHitTestParameters.cs
- CustomErrorsSection.cs
- SubqueryRules.cs
- FontFamily.cs
- AuthenticationService.cs
- RootProfilePropertySettingsCollection.cs
- ToolboxItemFilterAttribute.cs
- PageThemeCodeDomTreeGenerator.cs
- TimeStampChecker.cs
- Debug.cs
- TransformerConfigurationWizardBase.cs
- InternalsVisibleToAttribute.cs
- WebPartDescription.cs
- CacheRequest.cs
- EditingContext.cs
- ContentFilePart.cs
- CursorInteropHelper.cs
- CodeValidator.cs
- ValueTypeIndexerReference.cs
- ConfigurationStrings.cs
- ControlUtil.cs
- TextSerializer.cs
- BypassElement.cs
- PagerSettings.cs
- userdatakeys.cs
- DataGridViewRowPostPaintEventArgs.cs
- Timeline.cs
- IntSecurity.cs
- UnionExpr.cs
- FactoryGenerator.cs
- BinaryObjectReader.cs
- UnSafeCharBuffer.cs
- ConfigPathUtility.cs
- Transactions.cs
- GenericUriParser.cs
- SchemaImporter.cs
- RangeValidator.cs
- XmlFormatReaderGenerator.cs
- MouseGestureValueSerializer.cs
- SiblingIterators.cs
- handlecollector.cs
- ThemeDirectoryCompiler.cs
- NativeMethods.cs
- GeneralTransform3DTo2DTo3D.cs
- DataBoundControlAdapter.cs
- designeractionlistschangedeventargs.cs
- ErasingStroke.cs
- ResXBuildProvider.cs
- MarkedHighlightComponent.cs
- ListDictionary.cs
- RtfFormatStack.cs
- EdgeProfileValidation.cs
- ElementProxy.cs
- EdmItemError.cs
- ColumnMapVisitor.cs
- SingleStorage.cs
- TypedMessageConverter.cs
- Odbc32.cs
- CFStream.cs
- DataViewListener.cs
- SplitterEvent.cs
- WmlValidatorAdapter.cs
- AutoGeneratedFieldProperties.cs
- ToolboxCategory.cs
- ReadOnlyNameValueCollection.cs
- Geometry.cs
- SqlUDTStorage.cs
- WebPartMenuStyle.cs
- CultureInfoConverter.cs
- OdbcReferenceCollection.cs
- MsmqTransportSecurity.cs
- ErrorRuntimeConfig.cs
- HwndStylusInputProvider.cs
- SizeKeyFrameCollection.cs
- ContainerParaClient.cs
- ProviderCommandInfoUtils.cs
- TabItemWrapperAutomationPeer.cs
- DataAdapter.cs
- FontWeights.cs
- TreePrinter.cs
- OuterGlowBitmapEffect.cs
- DataSourceCacheDurationConverter.cs
- ResXResourceReader.cs