mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-04 22:07:40 +00:00
Add global lock on startup to prevent race conditions
This commit is contained in:
parent
40be8eee70
commit
6211bc4f42
10 changed files with 109 additions and 58 deletions
|
|
@ -9,11 +9,11 @@
|
|||
<StartupObject>FanControl.Program</StartupObject>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Version>0.1.0</Version>
|
||||
<ApplicationIcon>FanControl.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.1" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
<Content Include="FanControl.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
2
FanControl/FanControlForm.Designer.cs
generated
2
FanControl/FanControlForm.Designer.cs
generated
|
|
@ -69,7 +69,7 @@
|
|||
this.notifyIcon.ContextMenuStrip = this.contextMenu;
|
||||
this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon")));
|
||||
this.notifyIcon.Text = "Steam Deck Fan Control";
|
||||
this.notifyIcon.Visible = true;
|
||||
this.notifyIcon.Visible = false;
|
||||
this.notifyIcon.DoubleClick += new System.EventHandler(this.formShow_Event);
|
||||
//
|
||||
// contextMenu
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using CommonHelpers.FromLibreHardwareMonitor;
|
||||
using CommonHelpers;
|
||||
using CommonHelpers.FromLibreHardwareMonitor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
@ -27,7 +28,10 @@ namespace FanControl
|
|||
InitializeComponent();
|
||||
|
||||
Text += " v" + Application.ProductVersion.ToString();
|
||||
Instance.Open(Text, "Global\\FanControlOnce");
|
||||
|
||||
notifyIcon.Text = Text;
|
||||
notifyIcon.Visible = true;
|
||||
|
||||
toolStripMenuItemAlwaysOnTop.Checked = TopMost = Properties.Settings.Default.AlwaysOnTop;
|
||||
toolStripMenuItemStartupOnBoot.Visible = startupManager.IsAvailable;
|
||||
|
|
|
|||
|
|
@ -39,17 +39,8 @@ namespace FanControl
|
|||
[CategoryAttribute("Board")]
|
||||
public String PDVersion { get; private set; } = Vlv0100.GetFirmwareVersion().ToString("X");
|
||||
|
||||
private LibreHardwareMonitor.Hardware.Computer libreHardwareComputer = new LibreHardwareMonitor.Hardware.Computer
|
||||
{
|
||||
IsCpuEnabled = true,
|
||||
IsGpuEnabled = true,
|
||||
IsStorageEnabled = true,
|
||||
IsBatteryEnabled = true
|
||||
};
|
||||
|
||||
public FanController()
|
||||
{
|
||||
libreHardwareComputer.Open();
|
||||
}
|
||||
|
||||
private void visitHardware(IHardware hardware)
|
||||
|
|
@ -92,7 +83,7 @@ namespace FanControl
|
|||
foreach (var sensor in allSensors.Values)
|
||||
sensor.Reset();
|
||||
|
||||
foreach (var hardware in libreHardwareComputer.Hardware)
|
||||
foreach (var hardware in Instance.HardwareComputer.Hardware)
|
||||
visitHardware(hardware);
|
||||
|
||||
allSensors["Batt"].Update("VLV0100", Vlv0100.GetBattTemperature(), Mode);
|
||||
|
|
@ -131,7 +122,6 @@ namespace FanControl
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
libreHardwareComputer.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,20 +11,7 @@ namespace FanControl
|
|||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (!Vlv0100.IsSupported())
|
||||
{
|
||||
String message = "";
|
||||
message += "Current device is not supported.\n";
|
||||
message += "FirmwareVersion: " + Vlv0100.GetFirmwareVersion().ToString("X") + "\n";
|
||||
message += "BoardID: " + Vlv0100.GetBoardID().ToString("X") + "\n";
|
||||
message += "PDCS: " + Vlv0100.GetPDCS().ToString("X") + "\n";
|
||||
|
||||
String title = "Steam Deck Fan Control v" + Application.ProductVersion.ToString();
|
||||
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
Application.Run(new FanControlForm());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue