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 unsafe partial class Windows11 {12 internal sealed class SafeIoCompletionPort : SafeHandle13 {14 public SafeIoCompletionPort() : 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", SetLastError = true)]23 private static partial SafeIoCompletionPort CreateIoCompletionPort(24 nint FileHandle,25 nint ExistingCompletionPort,26 nint CompletionKey,27 int NumberOfConcurrentThreads);28 29 internal static SafeIoCompletionPort CreateIoCompletionPort()30 {31 return CreateIoCompletionPort(32 FileHandle: -1,33 ExistingCompletionPort: nint.Zero,34 CompletionKey: nint.Zero,35 NumberOfConcurrentThreads: 1);36 }37 }38}39 