Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: long time delay warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Sep 4, 2023
1 parent 21b972f commit 6df70b1
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using FFXIVClientStructs.FFXIV.Component.GUI;
using RotationSolver.Basic.Configuration;
using RotationSolver.Commands;
using RotationSolver.Localization;
using RotationSolver.UI;
using System.Runtime.InteropServices;

Expand All @@ -22,17 +23,12 @@ internal static class MajorUpdater
&& !Svc.Condition[ConditionFlag.BetweenAreas51]
&& Player.Available && !SocialUpdater.InPvp;

static bool _showed;
static bool _showed, _work;
static Exception _threadException;

static DateTime _lastUpdated = DateTime.Now;
static DateTime _lastUpdatedWork = DateTime.Now;

private unsafe static void FrameworkUpdate(Framework framework)
{
if (DateTime.Now - _lastUpdated < TimeSpan.FromSeconds(Service.Config.GetValue(PluginConfigFloat.MinUpdatingTime)))
return;
_lastUpdated = DateTime.Now;

PainterManager.ActionIds.Clear();
RotationSolverPlugin.UpdateDisplayWindow();
if (!IsValid)
Expand Down Expand Up @@ -87,6 +83,13 @@ private unsafe static void FrameworkUpdate(Framework framework)

try
{
if (_work) return;
if (DateTime.Now - _lastUpdatedWork < TimeSpan.FromSeconds(Service.Config.GetValue(PluginConfigFloat.MinUpdatingTime)))
return;

_work = true;
_lastUpdatedWork = DateTime.Now;

if (Service.Config.GetValue(PluginConfigBool.UseWorkTask))
{
Task.Run(UpdateWork);
Expand All @@ -110,18 +113,20 @@ public static void Enable()
Svc.Framework.Update += FrameworkUpdate;
}

static bool _work;
static Exception _innerException;
private static void UpdateWork()
{
var waitingTime = (DateTime.Now - _lastUpdatedWork).TotalMilliseconds;
if (waitingTime > 100)
{
PluginLog.Warning($"The time for completing a running cycle for RS is {waitingTime:F2} ms, try disabling the option \"{LocalizationManager.RightLang.ConfigWindow_Param_UseWorkTask}\" to get better performance or check your other running plugins for one of them using too many resources and try disabling that.");
}

if (!IsValid)
{
ActionUpdater.NextAction = ActionUpdater.NextGCDAction = null;
CustomRotation.MoveTarget = null;
return;
}
if (_work) return;
_work = true;

try
{
Expand Down

0 comments on commit 6df70b1

Please sign in to comment.