Skip to content

Commit

Permalink
Preparing Performance Setting Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 18, 2023
1 parent 855376a commit ca23e5f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void InitializeViewModel()

Counter.Title.Text = "Performans Sayaçları";
Counter.LeftIcon.Symbol = SymbolRegular.ShiftsActivity24;
Counter.Description.Text = "Tüm performans sayaçlarının çalışıp çalışmayacağı.";
Counter.Description.Text = "Tüm performans sayaçlarının arkaplanda çalışıp çalışmayacağı.";

ToggleSwitch CounterState = new()
{
Expand Down
68 changes: 52 additions & 16 deletions src/Project/Sucrose.Backgroundog/Helper/Initialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,66 @@ internal static class Initialize
{
public static void Start()
{
SBMI.InitializeTimer.Tick += new EventHandler(InitializeTimer_Tick);
SBMI.InitializeTimer.Interval = new TimeSpan(0, 0, 1);
SBMI.InitializeTimer.Start();
TimerCallback Callback = InitializeTimer_Callback;
SBMI.InitializeTimer = new(Callback, null, 0, 1000);
}

public static void Stop()
{
SBMI.InitializeTimer.Stop();
SBMI.InitializeTimer.Dispose();
}

private static void InitializeTimer_Tick(object sender, EventArgs e)
private static async void InitializeTimer_Callback(object State)
{
//Libredeki cpu, ram, net bilgileri değişkene atılacak
SBHC.Start();

if (SSSHL.Run())
{
//Performans şartları kontrol edilecek...
SBHP.Start();
}
else if (SBMI.Condition)
if (SBMI.Processing)
{
//Performans şartları sağlanıp live motoru kapatıldıysa veya durdurulduysa
//Live motoruna gRPC (Live.json) ile durdur mesajı gönderilir
SBMI.Processing = false;
Console.WriteLine("Callback");

//Libredeki cpu, ram, net bilgileri değişkene atılacak
SBHC.Start();

if (SSSHL.Run())
{
Console.WriteLine("Run");
//Performans şartları kontrol edilecek...
SBHP.Start();
}
else if (SBMI.Condition)
{
Console.WriteLine("Condition");
//Performans şartları sağlanıp live motoru kapatıldıysa veya durdurulduysa
//Live motoruna gRPC (Live.json) ile durdur mesajı gönderilir
}
else
{
Console.WriteLine("Deneme");
int MaxAttempts = 5;
bool Success = false;
int IntervalInSeconds = 1;

for (int Attempt = 0; Attempt <= MaxAttempts; Attempt++)
{
Success = SSSHL.Run();

if (Success)
{
Console.WriteLine("İşlem başarılı!");
break;
}

await Task.Delay(IntervalInSeconds * 1000);
}

if (!Success)
{
Console.WriteLine("İşlem başarısız oldu ve 5 deneme sonunda hala true dönmedi.");
SBMI.Exit = false;
Stop();
}
}

SBMI.Processing = true;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Windows.Threading;
using Timer = System.Threading.Timer;

namespace Sucrose.Backgroundog.Manage
{
Expand All @@ -10,6 +10,8 @@ internal static class Internal

public static bool Condition = false;

public static DispatcherTimer InitializeTimer = new();
public static bool Processing = true;

public static Timer InitializeTimer = null;
}
}
5 changes: 5 additions & 0 deletions src/Shared/Sucrose.Shared.Launcher/Command/Close.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public static void Command()
{
SSSHP.Kill(SMR.Commandog);
}

if (SSSHP.Work(SMR.Backgroundog))
{
SSSHP.Kill(SMR.Backgroundog);
}
}

WinForms.ExitThread();
Expand Down

0 comments on commit ca23e5f

Please sign in to comment.