Skip to content

Commit

Permalink
Attempt to fix service "soft crashes", part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Sep 7, 2024
1 parent 95dff7c commit 110e086
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
38 changes: 29 additions & 9 deletions YAMDCC.GUI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ private void MainWindow_Load(object sender, EventArgs e)
}

LoadConf(Path.Combine(DataPath, "CurrentConfig.xml"));

if (Config is not null && Config.KeyLightConf is not null)
{
ServiceCommand command = new(Command.GetKeyLightBright, "");
IPCClient.PushMessage(command);
}
}

private void MainWindow_Closing(object sender, FormClosingEventArgs e)
Expand All @@ -212,26 +218,45 @@ private void IPC_MessageReceived(object sender, PipeMessageEventArgs<ServiceResp
{
switch (e.Message.Response)
{
case Response.Success:
{
if (int.TryParse(args[0], out int value))
{
if ((Command)value == Command.ApplyConfig && Config.KeyLightConf is not null)
{
ServiceCommand command = new(Command.GetKeyLightBright, "");
IPCClient.PushMessage(command);
}
}
break;
}
case Response.Temp:
{
if (int.TryParse(args[0], out int value))
{
UpdateFanMon(value, 0);
}
break;
}
case Response.FanSpeed:
if (int.TryParse(args[0], out value))
{
if (int.TryParse(args[0], out int value))
{
UpdateFanMon(value, 1);
}
break;
}
case Response.FanRPM:
if (int.TryParse(args[0], out value))
{
if (int.TryParse(args[0], out int value))
{
UpdateFanMon(value, 2);
}
break;
}
case Response.KeyLightBright:
if (int.TryParse(args[0], out value))
{
if (int.TryParse(args[0], out int value))
{
tbKeyLight.Invoke(new Action(delegate
{
Expand All @@ -241,6 +266,7 @@ private void IPC_MessageReceived(object sender, PipeMessageEventArgs<ServiceResp
}));
}
break;
}
}
}
}
Expand Down Expand Up @@ -700,12 +726,6 @@ private void LoadConf(string configPath)
chkWinFnSwap.Enabled = lblWinFnSwap.Enabled = true;
}

if (Config.KeyLightConf is not null)
{
ServiceCommand command = new(Command.GetKeyLightBright, "");
IPCClient.PushMessage(command);
}

cboFanSel.Items.Clear();
for (int i = 0; i < Config.FanConfs.Length; i++)
{
Expand Down
2 changes: 2 additions & 0 deletions YAMDCC.Service/svcFanControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ private void IPCClientMessage(object sender, PipeMessageEventArgs<ServiceCommand
case Command.ApplyConfig:
LoadConf();
ApplySettings();
ServiceResponse response = new(Response.Success, $"{(int)e.Message.Command}");
IPCServer.PushMessage(response, e.Connection.ID);
error = 0;
break;
case Command.FullBlast:
Expand Down

0 comments on commit 110e086

Please sign in to comment.