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
- ObjectQueryProvider.cs
- ClassValidator.cs
- COAUTHINFO.cs
- CanonicalFormWriter.cs
- Processor.cs
- SqlTransaction.cs
- WsdlParser.cs
- RSAPKCS1SignatureDeformatter.cs
- DecoratedNameAttribute.cs
- __TransparentProxy.cs
- RowToParametersTransformer.cs
- FixedStringLookup.cs
- XmlSchemaValidator.cs
- HandleCollector.cs
- CodeDirectoryCompiler.cs
- TextEvent.cs
- XpsFilter.cs
- GrammarBuilder.cs
- TypeInitializationException.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- AuthorizationRuleCollection.cs
- FrugalList.cs
- TemplateContainer.cs
- ClaimTypes.cs
- ElementsClipboardData.cs
- FormViewCommandEventArgs.cs
- ResourcePool.cs
- DataObjectFieldAttribute.cs
- Tuple.cs
- ISAPIRuntime.cs
- BaseDataBoundControlDesigner.cs
- GregorianCalendar.cs
- _OverlappedAsyncResult.cs
- DataGridTableCollection.cs
- CheckBox.cs
- Quad.cs
- StatusBarItem.cs
- Bits.cs
- GridViewUpdatedEventArgs.cs
- StrokeNode.cs
- QuerySafeNavigator.cs
- PlaceHolder.cs
- RegexCapture.cs
- WindowsRegion.cs
- RootContext.cs
- SmiGettersStream.cs
- ClientScriptItem.cs
- DeferredReference.cs
- OutOfProcStateClientManager.cs
- SvcMapFile.cs
- DotAtomReader.cs
- RegexCharClass.cs
- BoundField.cs
- XsdCachingReader.cs
- ModelItemKeyValuePair.cs
- GiveFeedbackEvent.cs
- wgx_sdk_version.cs
- WebResourceUtil.cs
- ControlTemplate.cs
- ToolboxDataAttribute.cs
- OleDbPropertySetGuid.cs
- DataKeyArray.cs
- autovalidator.cs
- CapabilitiesAssignment.cs
- Event.cs
- Errors.cs
- Point3DAnimationBase.cs
- EntryWrittenEventArgs.cs
- CqlIdentifiers.cs
- GeneralTransform2DTo3D.cs
- KnownBoxes.cs
- CollectionBase.cs
- GZipDecoder.cs
- InlinedAggregationOperatorEnumerator.cs
- SiteMapNodeItemEventArgs.cs
- ScrollContentPresenter.cs
- DesignColumn.cs
- CardSpacePolicyElement.cs
- HashCryptoHandle.cs
- QueryResponse.cs
- TimeoutHelper.cs
- BaseProcessor.cs
- IPipelineRuntime.cs
- PackageFilter.cs
- UnsafeNativeMethods.cs
- regiisutil.cs
- DesignColumn.cs
- relpropertyhelper.cs
- AppDomainAttributes.cs
- SettingsSavedEventArgs.cs
- MatrixCamera.cs
- UIElementAutomationPeer.cs
- KeyedCollection.cs
- SqlTransaction.cs
- LogStream.cs
- ServiceModelStringsVersion1.cs
- Helper.cs
- AppLevelCompilationSectionCache.cs
- NativeMethods.cs
- XmlUtil.cs