Ensure CimSession is properly disposed.

This commit is contained in:
sunshineinabox 2023-07-21 18:42:49 -07:00
parent cc8f4f8a11
commit 31c36afc4c

View file

@ -93,11 +93,13 @@ namespace Ryujinx.Common.SystemInfo
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
var session = CimSession.Create(null); using (var session = CimSession.Create(null))
var instances = session.QueryInstances(@"root\cimv2", "WQL", "SELECT NumberOfCores FROM Win32_Processor");
foreach (CimInstance instance in instances)
{ {
coreCount = int.Parse(instance.CimInstanceProperties["NumberOfCores"].Value.ToString()); var instances = session.QueryInstances(@"root\cimv2", "WQL", "SELECT NumberOfCores FROM Win32_Processor");
foreach (CimInstance instance in instances)
{
coreCount = int.Parse(instance.CimInstanceProperties["NumberOfCores"].Value.ToString());
}
} }
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))