public TethrHeartbeatTimerSample(ITethrHeartbeat heartbeat)
 {
     _heartbeat = heartbeat;
     // Using due time and not period in timer so that if our call to Tethr
     // takes longer then then the period, we don't try to send two at a time.
     _internalTimer = new Timer(Callback, null, Period, 0);
 }
Exemple #2
0
        public static async Task Send(this ITethrHeartbeat heartbeat, MonitorStatus monitorStatus)
        {
            var             assembly        = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = null;

            if (assembly.Location != null)
            {
                fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
            }

            await heartbeat.Send(new MonitorEvent
            {
                Name            = Environment.MachineName,
                Status          = monitorStatus,
                TimeStamp       = DateTimeOffset.UtcNow,
                SoftwareVersion = fileVersionInfo?.ProductVersion
            });
        }