On device, when in Windows, tell .NET Framework to close the handle, to prevent an exception raised when GC collects it.

This commit is contained in:
2018-12-01 19:34:05 +00:00
parent 3a0b9b634f
commit b2dbcc6149

View File

@@ -31,7 +31,7 @@
// ****************************************************************************/
using System;
using DiscImageChef.Devices.Windows;
using DiscImageChef.Devices.Linux;
using Microsoft.Win32.SafeHandles;
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
@@ -55,10 +55,10 @@ namespace DiscImageChef.Devices
switch(PlatformId)
{
case PlatformID.Win32NT:
Extern.CloseHandle((SafeFileHandle)FileHandle);
(FileHandle as SafeFileHandle)?.Close();
break;
case PlatformID.Linux:
Linux.Extern.close((int)FileHandle);
Extern.close((int)FileHandle);
break;
case PlatformID.FreeBSD:
FreeBSD.Extern.cam_close_device((IntPtr)FileHandle);