Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / SafeJobHandle.cs / 1 / SafeJobHandle.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // // Presharp uses the c# pragma mechanism to supress its warnings. // These are not recognised by the base compiler so we need to explictly // disable the following warnings. See http://winweb/cse/Tools/PREsharp/userguide/default.asp // for details. // #pragma warning disable 1634, 1691 // unknown message, unknown pragma namespace Microsoft.InfoCards { using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using Microsoft.Win32.SafeHandles; // // Summary: // This is a wrapper for Win32 Job handles that ensures that they get closed and that the handle // held by this object isn't recycled. // internal sealed class SafeJobHandle : SafeHandle { [DllImport("Kernel32.dll", EntryPoint ="TerminateJobObject", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true ) ] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [SuppressUnmanagedCodeSecurity] private static extern bool TerminateJobObject( [In] IntPtr hJob, [In] UInt32 uExitCode ); public SafeJobHandle() : base( IntPtr.Zero, true ) { } public override bool IsInvalid { get { return ( IntPtr.Zero == base.handle ); } } [ReliabilityContract( Consistency.WillNotCorruptState, Cer.Success ) ] public void UpdateHandle( IntPtr handle ) { base.SetHandle( handle ); } override protected bool ReleaseHandle() { // // Presharp: failure of TerminateJobObject is part of the desired behavior of this function, // hence we have no need for calling GetLastW32Error. // #pragma warning suppress 56523 TerminateJobObject( handle, 0 ); // // Presharp: once again, this function's design is to return the result of success or failure from // these native calls. // #pragma warning suppress 56523 return NativeMethods.SafeHandleOnlyMethods.CloseHandle( handle ); } } } // 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
- DynamicQueryableWrapper.cs
- ExpressionBindingCollection.cs
- XmlDocumentFieldSchema.cs
- EncoderBestFitFallback.cs
- DesignerDataTable.cs
- XmlObjectSerializerReadContextComplex.cs
- Debug.cs
- DropShadowEffect.cs
- SynchronousChannelMergeEnumerator.cs
- BrowserCapabilitiesCompiler.cs
- CustomErrorsSection.cs
- AuthStoreRoleProvider.cs
- PersonalizablePropertyEntry.cs
- ReverseQueryOperator.cs
- TemplateBuilder.cs
- NativeMethods.cs
- ChooseAction.cs
- Encoder.cs
- IISUnsafeMethods.cs
- UInt16.cs
- StreamInfo.cs
- WebBrowserDocumentCompletedEventHandler.cs
- ModelPerspective.cs
- InsufficientMemoryException.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- NativeObjectSecurity.cs
- SequentialUshortCollection.cs
- ActivityBuilder.cs
- AsyncStreamReader.cs
- SqlGatherProducedAliases.cs
- SafeSecurityHandles.cs
- Hyperlink.cs
- AppDomainGrammarProxy.cs
- ResizeGrip.cs
- SliderAutomationPeer.cs
- NameGenerator.cs
- NetSectionGroup.cs
- ArgumentException.cs
- PlainXmlSerializer.cs
- BindingSource.cs
- TransformerConfigurationWizardBase.cs
- XmlQualifiedName.cs
- DiagnosticEventProvider.cs
- ControlBuilder.cs
- ToolStripContentPanelRenderEventArgs.cs
- Enum.cs
- ZoomingMessageFilter.cs
- Rss20FeedFormatter.cs
- EntityDataSource.cs
- SectionVisual.cs
- DataContractSerializerSection.cs
- ToolstripProfessionalRenderer.cs
- StorageAssociationTypeMapping.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ByteStreamGeometryContext.cs
- PathTooLongException.cs
- DefaultAsyncDataDispatcher.cs
- DtdParser.cs
- NavigationPropertyEmitter.cs
- StringInfo.cs
- IntSumAggregationOperator.cs
- FlowPanelDesigner.cs
- RandomNumberGenerator.cs
- DropDownList.cs
- ToolBarOverflowPanel.cs
- URLMembershipCondition.cs
- PolicyStatement.cs
- PartialList.cs
- UnknownBitmapDecoder.cs
- VirtualPathProvider.cs
- OleDbRowUpdatingEvent.cs
- WebResourceUtil.cs
- TypedDatasetGenerator.cs
- RawStylusInput.cs
- Region.cs
- DataViewListener.cs
- VideoDrawing.cs
- BitmapSource.cs
- AuthenticationManager.cs
- CorrelationKey.cs
- CreateUserWizardStep.cs
- StyleTypedPropertyAttribute.cs
- Context.cs
- Validator.cs
- Padding.cs
- ConvertTextFrag.cs
- NullRuntimeConfig.cs
- FatalException.cs
- HttpResponseInternalBase.cs
- MultiView.cs
- AssemblyCollection.cs
- EncodingDataItem.cs
- FormsAuthentication.cs
- SoapAttributeOverrides.cs
- NegotiateStream.cs
- TypedElement.cs
- AsyncStreamReader.cs
- PaintEvent.cs
- safemediahandle.cs
- AxisAngleRotation3D.cs