private PerformanceCounter GetCounter(string category, string counterName, string instanseName = null) { PerformanceCounter counter = null; try { counter = instanseName != null ? new PerformanceCounter(category, counterName, instanseName) : new PerformanceCounter(category, counterName); } catch { _logger.LogError($"Performance counter {category} {counterName} not exist in current machine"); } return(counter); }
public void Start(string ip, int port) { try { _client = new WatsonTcpClient(ip, port) { ServerConnected = SuccessfullyСonnected, Debug = false }; _client.Start(); } catch { MessageBox.Show(Properties.Resources.ServerNotAvaible, "Error", MessageBoxButton.OK, MessageBoxImage.Error); _logger.LogError("Server is not available"); } }
public void LoadSettingsCounter() { try { using (var fs = new FileStream(_configurationPath, FileMode.Open)) { var counters = (List <SystemCharacterNode>)_serializer.Deserialize(fs); SettingsCounters = counters.ToDictionary(c => c.Name, c => c); } } catch { _logger.LogError("The cache file was damaged, a new file will be created"); UploadSettingsCounter(); } SetSettingsCounter(); }