Files
PowerShell/src/Microsoft.PowerShell.Commands.Diagnostics/PdhSafeHandle.cs
T
PowerShell Team 403ae3f53f Initial run of code formatter
I (Jason Shirk) ran https://github.com/dotnet/codeformatter with the default rules, basically:

    codeformatter /nocopyright "/c:DEBUG,UNIX,CORECLR" @files.rsp

This caused a few problems building, which were fixed up manually.

Notable changes:

`this.` is removed unless needed to disambiguate.
private instance fields are renamed to have a `_` prefix.
private static fields are renamed to have a `s_` prefix.

I left some projects alone (like PackageManagement) and also left some generated code alone.
2016-08-01 15:57:03 -07:00

76 lines
1.7 KiB
C#

//
// Copyright (C) Microsoft. All rights reserved.
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Powershell.Commands.GetCounter.PdhNative
{
internal sealed class PdhSafeDataSourceHandle : SafeHandle
{
private PdhSafeDataSourceHandle() : base(IntPtr.Zero, true) { }
public override bool IsInvalid
{
get
{
return handle == IntPtr.Zero;
}
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
return (PdhHelper.PdhCloseLog(handle, 0) == 0);
}
}
internal sealed class PdhSafeQueryHandle : SafeHandle
{
private PdhSafeQueryHandle() : base(IntPtr.Zero, true) { }
public override bool IsInvalid
{
get
{
return handle == IntPtr.Zero;
}
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
return (PdhHelper.PdhCloseQuery(handle) == 0);
}
}
internal sealed class PdhSafeLogHandle : SafeHandle
{
private PdhSafeLogHandle() : base(IntPtr.Zero, true) { }
public override bool IsInvalid
{
get
{
return handle == IntPtr.Zero;
}
}
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
return (PdhHelper.PdhCloseLog(handle, 0) == 0);
}
}
}