public static void DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bw = sender as BackgroundWorker; initializePerformanceCounters(); while (!bw.CancellationPending) { // If more than reportTimeSpan was passed since we last logged values, log them DateTime now = DateTime.UtcNow; if (now.Subtract(reportingTimeSpan) > lastReportedTime) { // Report WCF connection status logger.Debug($"Connections-> Total:({pc_sms_calls.NextValue()}) Outstanding:({pc_sms_callsOutstanding.NextValue()}) " + $"Faulted:({pc_sms_callsFaulted.NextValue()}) Failed:({pc_sms_callsFailed.NextValue()}) " + $" Max% ({pc_sms_pctMaxCalls.NextValue()})%" ); ServiceDataSnapshot snapshot = new ServiceDataSnapshot(); // Report internal data sizes logger.Debug($"Users-> active({snapshot.num_connections_active}) inactive:({snapshot.num_connections_inactive}) percent active:({snapshot.percent_connections_active})"); logger.Debug($"ResultsHistory-> total objects:({snapshot.num_results}) before_inactivity:({snapshot.num_results_past_inactive_time})"); string json_inventory_size = JsonConvert.SerializeObject(snapshot.faction_inventory_size); string json_faction_shops = JsonConvert.SerializeObject(snapshot.faction_shop_size); logger.Debug($"Faction inventory: {json_inventory_size}"); logger.Debug($"Faction shop size: {json_faction_shops}"); lastReportedTime = now; } // Sleep a short period to see if we are cancelled. Thread.Sleep(50); } }
public override ServiceDataSnapshot GetServiceDataSnapshot() { ServiceDataSnapshot snapshot = new ServiceDataSnapshot(); return(snapshot); }