1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

Stats thread safe

Cleaned up WebService class and shutdown
reimped stats and topstats
moved things out of stats into main code
This commit is contained in:
RaidMax
2018-02-10 00:26:38 -06:00
parent 293d439760
commit d1cdb93cc3
31 changed files with 668 additions and 927 deletions

View File

@ -9,17 +9,17 @@ namespace SharedLibrary.Helpers
{
public sealed class AsyncStatus
{
CancellationToken Token;
DateTime StartTime;
int TimesRun;
int UpdateFrequency;
public double RunAverage { get; private set; }
public object Dependant { get; private set; }
public Task RequestedTask { get; private set; }
public CancellationTokenSource TokenSrc { get; private set; }
public AsyncStatus(object dependant, int frequency)
{
Token = new CancellationToken();
TokenSrc = new CancellationTokenSource();
StartTime = DateTime.Now;
Dependant = dependant;
UpdateFrequency = frequency;
@ -29,7 +29,7 @@ namespace SharedLibrary.Helpers
public CancellationToken GetToken()
{
return Token;
return TokenSrc.Token;
}
public double ElapsedMillisecondsTime()
@ -39,6 +39,10 @@ namespace SharedLibrary.Helpers
public void Update(Task<bool> T)
{
// reset the token source
TokenSrc.Dispose();
TokenSrc = new CancellationTokenSource();
RequestedTask = T;
// Console.WriteLine($"Starting Task {T.Id} ");
RequestedTask.Start();