File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ Public Class MainWindow
1414 Dim Powercfg As PowercfgInterface.Instance
1515 Dim dispatcherTimer As DispatcherTimer
1616
17+ Dim _computer As Computer
18+
1719 Public Async Function PreInit() As Task( Of Boolean )
1820 Title = "聚能环 PowerRing " + Assembly .GetEntryAssembly().GetName().Version.ToString()
1921 If Not StartMonitor() Then
@@ -57,8 +59,9 @@ Public Class MainWindow
5759 Return True
5860 End Function
5961 Private Function GPUFinder() As Boolean
60- Dim _computer = New Computer()
61- _computer.IsGpuEnabled = True
62+ _computer = New Computer With {
63+ .IsGpuEnabled = True
64+ }
6265 _computer.Open()
6366 For i As Integer = 0 To _computer.Hardware.Count() - 1
6467 If _computer.Hardware(i).Name = My.Settings.GPUDevice Then
@@ -210,12 +213,13 @@ Public Class MainWindow
210213 End Sub
211214
212215 Private Sub MainWindow_Closing(sender As Object , e As CancelEventArgs) Handles Me .Closing
213- If runWorker And InSupress Then
214- ExitSupress()
215- End If
216216 If GPUPowerSensor Is Nothing Then
217217 Return
218218 End If
219+ If runWorker And InSupress Then
220+ ExitSupress()
221+ End If
222+ _computer.Close()
219223 For Each val As System.Configuration.SettingsProperty In My.Settings.Properties
220224 Dim Element = FindName(val.Name)
221225 If Element Is Nothing Then
Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ Public Class SelectWindow
66 Private GPUList = New List( Of IHardware)
77 Private SensorList = New List( Of ISensor)
88 Private SelectedSensor As ISensor
9+ Private _computer As Computer
910 Public Async Function PreInit() As Task
1011 Await Task.Run( Sub ()
11- Dim _computer = New Computer With {
12+ _computer = New Computer With {
1213 .IsGpuEnabled = True
1314 }
1415 _computer.Open()
@@ -64,6 +65,7 @@ Public Class SelectWindow
6465 My.Settings.Sensor = SelectedSensor.Name
6566 My.Settings.GPUSelected = True
6667 My.Settings.Save()
68+ _computer.Close()
6769 Dim InitWindow = New Init()
6870 InitWindow.Show()
6971 Close()
You can’t perform that action at this time.
0 commit comments