private void WaitTimeLengthCallback(object status) { ClearTimer(); FinishedStamp = DateTime.UtcNow; BetLog += string.Format("\n\rBETEND Calc:{0} Real:{1} Delta(seconds):{2}", Timestamp.AddSeconds(Box.TimeToGraph + Box.TimeLength).ToTimeString(), FinishedStamp.Value.ToTimeString(), (FinishedStamp.Value - Timestamp.AddSeconds(Box.TimeToGraph + Box.TimeLength)).TotalSeconds); TimeLenghFinished?.Invoke(this, new EventArgs()); }
public GibraltarRateLimitException(string message, TimeSpan?delay) : base(message) { Timestamp = DateTimeOffset.Now; Delay = delay; if (delay.HasValue) { RetryAfter = Timestamp.Add(delay.Value); } else { RetryAfter = Timestamp.AddSeconds(1); } }
private void WaitTimeToGraphCallback(object status) { ClearTimer(); TimeToGraphStamp = DateTime.UtcNow; BetStatus = BetStates.OnGoing; BetLog += string.Format("\n\rGRAPHR Calc:{0} Real:{1} Delta(seconds):{2}", Timestamp.AddSeconds(Box.TimeToGraph).ToTimeString(), TimeToGraphStamp.Value.ToTimeString(), (TimeToGraphStamp.Value - Timestamp.AddSeconds(Box.TimeToGraph)).TotalSeconds); BetTimer = new System.Threading.Timer(new System.Threading.TimerCallback(WaitTimeLengthCallback), Box, (int)(1000 * Box.TimeLength), -1); TimeToGraphReached?.Invoke(this, new EventArgs()); }
public bool IsActive(DateTime now) { if (InvalidSuspension) { return(false); } if (SuspensionType == SuspensionType.Ban) { return(true); } var expires = Timestamp.AddSeconds(Duration); return(expires >= now); }
public override async Task Shutdown() { shutdown = true; if (process == null) { return; } var taskAbort = SendVoidRequest(new ShutdownMsg()); try { Timestamp tStart = Timestamp.Now; const int timeout = 8; while (!taskAbort.IsCompleted) { if (process.HasExited) { Console.Out.WriteLine("External adapter terminated unexpectedly during shutdown."); break; } if (Timestamp.Now - tStart > Duration.FromSeconds(timeout)) { Console.Out.WriteLine($"Adapter did not return from Shutdown within {timeout} seconds. Killing process..."); break; } await Task.WhenAny(taskAbort, Task.Delay(2000)); if (!taskAbort.IsCompleted) { long secondsUntilTimeout = (tStart.AddSeconds(timeout) - Timestamp.Now).TotalMilliseconds / 1000; Console.Out.WriteLine("Waiting for Shutdown completion (timeout in {0} seconds)...", secondsUntilTimeout); } } } finally { connection?.Close("Shutdown"); StopProcess(process); process = null; } }
public Timestamp GetBlockTime() { return(_blockTime == null?TimestampHelper.GetUtcNow() : _blockTime.AddSeconds(DelaySeconds)); }