Beispiel #1
0
        private void StartIndexerTimer()
        {
            indexerTimer.AutoReset = false; // Make sure it only trigger once initially.

            indexerTimer.Elapsed += (sender, args) =>
            {
                if (indexerTimer.AutoReset == false)
                {
                    indexerTimer.Interval  = TimeSpan.FromSeconds(30).TotalMilliseconds;
                    indexerTimer.AutoReset = true;
                }

                try
                {
                    // Get statistics and cache it.
                    memoryCache.Set("BlockchainStats", blockIndexService.GetStatistics());
                }
                catch (Exception ex)
                {
                    log.LogError(ex, "Failed to set blockchain stats cache.");
                }
            };

            indexerTimer.Start();
        }