mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
More Logging
This commit is contained in:
@@ -75,7 +75,7 @@ public static class Tranga
|
|||||||
|
|
||||||
public static void AddWorker(BaseWorker worker)
|
public static void AddWorker(BaseWorker worker)
|
||||||
{
|
{
|
||||||
Log.Debug($"Adding {worker}");
|
Log.Debug($"Adding Worker {worker}");
|
||||||
StartWorker(worker);
|
StartWorker(worker);
|
||||||
if(worker is IPeriodic periodic)
|
if(worker is IPeriodic periodic)
|
||||||
AddPeriodicWorker(worker, periodic);
|
AddPeriodicWorker(worker, periodic);
|
||||||
@@ -90,7 +90,7 @@ public static class Tranga
|
|||||||
|
|
||||||
private static Task PeriodicTask(BaseWorker worker, IPeriodic periodic) => new (() =>
|
private static Task PeriodicTask(BaseWorker worker, IPeriodic periodic) => new (() =>
|
||||||
{
|
{
|
||||||
Log.Debug($"Waiting {periodic.Interval} for {worker}");
|
Log.Debug($"Waiting {periodic.Interval} for next run of {worker}");
|
||||||
Thread.Sleep(periodic.Interval);
|
Thread.Sleep(periodic.Interval);
|
||||||
StartWorker(worker, RefreshTask(worker, periodic));
|
StartWorker(worker, RefreshTask(worker, periodic));
|
||||||
});
|
});
|
||||||
@@ -99,6 +99,7 @@ public static class Tranga
|
|||||||
{
|
{
|
||||||
if (worker.State < WorkerExecutionState.Created) //Failed
|
if (worker.State < WorkerExecutionState.Created) //Failed
|
||||||
return;
|
return;
|
||||||
|
Log.Debug($"Refreshing {worker}");
|
||||||
PeriodicWorkers[(worker as IPeriodic)!] = PeriodicTask(worker, periodic);
|
PeriodicWorkers[(worker as IPeriodic)!] = PeriodicTask(worker, periodic);
|
||||||
PeriodicWorkers[(worker as IPeriodic)!].Start();
|
PeriodicWorkers[(worker as IPeriodic)!].Start();
|
||||||
};
|
};
|
||||||
@@ -139,12 +140,14 @@ public static class Tranga
|
|||||||
|
|
||||||
private static Action AfterWork(BaseWorker worker, Action? callback) => () =>
|
private static Action AfterWork(BaseWorker worker, Action? callback) => () =>
|
||||||
{
|
{
|
||||||
|
Log.Debug($"AfterWork {worker}");
|
||||||
RunningWorkers.Remove(worker, out _);
|
RunningWorkers.Remove(worker, out _);
|
||||||
callback?.Invoke();
|
callback?.Invoke();
|
||||||
};
|
};
|
||||||
|
|
||||||
internal static void StopWorker(BaseWorker worker)
|
internal static void StopWorker(BaseWorker worker)
|
||||||
{
|
{
|
||||||
|
Log.Debug($"Stopping {worker}");
|
||||||
if(worker is IPeriodic periodicWorker)
|
if(worker is IPeriodic periodicWorker)
|
||||||
PeriodicWorkers.Remove(periodicWorker);
|
PeriodicWorkers.Remove(periodicWorker);
|
||||||
worker.Cancel();
|
worker.Cancel();
|
||||||
|
Reference in New Issue
Block a user