MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4#nullable enable5 6using System.Runtime.InteropServices;7 8internal static partial class Interop9{10 internal static partial class Windows11 {12 internal sealed class SafeJobHandle : SafeHandle13 {14 public SafeJobHandle() : base(invalidHandleValue: nint.Zero, ownsHandle: true) { }15 16 public override bool IsInvalid => handle == nint.Zero;17 18 protected override bool ReleaseHandle()19 => Windows.CloseHandle(handle);20 }21 22 [LibraryImport("kernel32.dll", EntryPoint = "CreateJobObjectW", SetLastError = true)]23 private static partial SafeJobHandle CreateJobObject(24 nint lpJobAttributes,25 nint lpName);26 27 internal static SafeJobHandle CreateJobObject()28 => CreateJobObject(nint.Zero, nint.Zero);29 }30}31 