private async void AliveSendTimer_Elapsed(object sender, ElapsedEventArgs e) { try { if (!Connected || !State.SystemsAlive) { return; } var ao = new AliveObject { Ticks = TLCFIClient.CurrentTicks, Time = TimestampGenerator.GetTimestamp() }; var reply = await TLCProxy.AliveAsync(ao, _sessionCancellationToken); if (reply != null && reply.Ticks == ao.Ticks && reply.Time == ao.Time) { return; } _aliveSendFailCounter++; if (_aliveSendFailCounter > 2) { StopAliveTimers(); SendAliveTimeoutOccured?.Invoke(this, EventArgs.Empty); } } catch { // ignored } }
public void ProgramStarts_GetTimestampCalled_ReturnsTimeSince1970() { var t = TimestampGenerator.GetTimestamp(); var timenow = DateTime.Now; // Check year and days Assert.AreEqual(timenow.Year - 1970, (int)(t / 31557600000)); // TODO need to round days upwards Assert.AreEqual( timenow.DayOfYear - 1 + Math.Round((timenow.Year - 1970) * 365.25) + ((((timenow.Year - 1970) * 365.25) % 1.0) > 0 ? 1 : 0), (int)(t / 86400000)); }
public async Task WriteMessages(IEnumerable <WriteMessage> messages, Consistency?consistency = null, string retentionPolicy = null) { await RequestProcessor.WriteMessages(Database, messages, consistency ?? DefaultConsistency, retentionPolicy, TimestampGenerator.GetTimestamp(), TimestampGenerator.Precision).ConfigureAwait(false); }