public static void CloseHandle(IntPtr handle) { // Check if the handle is valid ValidateAsArgument(handle, "handle"); // Close the handle if(!NativeMethods.CloseHandle(handle)) throw new Win32Exception("Couldn't close the handle correctly."); }