From 747017de1a776e8962b4e0ab6c177e12bbfe7f5f Mon Sep 17 00:00:00 2001 From: Hedi Hadi <84453910+hedihadi@users.noreply.github.com> Date: Sun, 7 Apr 2024 20:41:36 +0300 Subject: [PATCH] fixed fps screen not working --- .../Backend/HelperFunctions/FpsDataGetter.cs | 104 ++++++++++-------- zal_program/Zal/Zal.csproj | 6 +- 2 files changed, 61 insertions(+), 49 deletions(-) diff --git a/zal_program/Zal/Backend/HelperFunctions/FpsDataGetter.cs b/zal_program/Zal/Backend/HelperFunctions/FpsDataGetter.cs index ee4e7e2..b681abb 100644 --- a/zal_program/Zal/Backend/HelperFunctions/FpsDataGetter.cs +++ b/zal_program/Zal/Backend/HelperFunctions/FpsDataGetter.cs @@ -96,69 +96,81 @@ private async Task parseIncomingPresentmonData() while (!reader.EndOfStream) { - if (isDisposed) break; - //Thread.Sleep(30); - string line = reader.ReadLine(); - if (shouldLog) Logger.Log($"fpsData:{line}"); - var msBetweenPresents = ""; try { - msBetweenPresents = line.Split(',')[9]; - } - catch - { - Logger.Log("skipped line, msBetweenPresents failed"); - continue; - } + if (isDisposed) + { + Logger.Log("presentmon disposed, stopping fps"); + break; + } + //Thread.Sleep(30); + string line = reader.ReadLine(); + if (shouldLog) Logger.Log($"fpsData:{line}"); + var msBetweenPresents = ""; + try + { + msBetweenPresents = line.Split(',')[9]; + } + catch + { + Logger.Log("skipped line, msBetweenPresents failed"); + continue; + } - uint? processId = null; - String? processName = line.Split(',')[0]; - try - { - processId = uint.Parse(line.Split(',')[1]); - } - catch - { - Logger.Log("skipped line, processId failed"); - } - if (processName == "") - { - Logger.Log("skipped line, error line"); - continue; - } + uint? processId = null; + String? processName = line.Split(',')[0]; + try + { + processId = uint.Parse(line.Split(',')[1]); + } + catch + { + Logger.Log("skipped line, processId failed"); + } + if (processName == "") + { + Logger.Log("skipped line, error line"); + continue; + } - if (processId != null) - { - var time = getTimestamp(); - if (msBetweenPresents.Any(char.IsDigit)) + if (processId != null) { - var doubledMsBetweenPresents = double.Parse(msBetweenPresents); - fpsDatas.Add((1000 / doubledMsBetweenPresents)); + var time = getTimestamp(); + if (msBetweenPresents.Any(char.IsDigit)) + { + var doubledMsBetweenPresents = double.Parse(msBetweenPresents, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo); + fpsDatas.Add((1000 / doubledMsBetweenPresents)); - if (fpsDatas.Count > 10) - { - try - { - sendFpsData.Invoke(null, fpsDatas); - } - catch (Exception exc) + if (fpsDatas.Count > 10) { - Logger.LogError("error sending fps data", exc); + try + { + sendFpsData.Invoke(null, fpsDatas); + } + catch (Exception exc) + { + Logger.LogError("error sending fps data", exc); + } + fpsDatas.Clear(); } - fpsDatas.Clear(); + continue; + } + else + { + Logger.Log("msBetweenPresents not digits"); } - continue; } else { - Logger.Log("msBetweenPresents not digits"); + Logger.Log("processId is null"); } } - else + catch (Exception exc) { - Logger.Log("processId is null"); + Logger.LogError("error during fps", exc); } + } } diff --git a/zal_program/Zal/Zal.csproj b/zal_program/Zal/Zal.csproj index 7f4742f..556a352 100644 --- a/zal_program/Zal/Zal.csproj +++ b/zal_program/Zal/Zal.csproj @@ -9,13 +9,13 @@ net7.0-windows10.0.17763.0 true true - 1.7.5 + 1.7.6 white.ico preview False AnyCPU - 1.7.5 - 1.7.5 + 1.7.6 + 1.7.6 9999