private void LoadCategories(string machineName) { Collection <PerformanceCounterCategory> categories = null; try { categories = PerfMonController.GetCategories(machineName); category_ListBox.DataSource = categories; category_ListBox.DisplayMember = "CategoryName"; category_ListBox.SelectedIndex = -1; } catch (Win32Exception w32Exception) { TraceFactory.Logger.Error(w32Exception); DialogResult dialogResult = MessageBox.Show("Could not load categories for {0}. \nLoad from local machine?".FormatWith(machineName), "Unreachable Host", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { //This will cause the SelectedIndex value to change which will indirectly call LoadCategories again. LoadLocalHost(); } } catch (UnauthorizedAccessException unauthException) { TraceFactory.Logger.Error(unauthException); MessageBox.Show("Failed to login to {0}. \nPlease check the user credentials being used.".FormatWith(machineName), "Authorization Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void LoadCategoriesImpl(string machineName) { Collection <PerformanceCounterCategory> categories = PerfMonController.GetCategories(machineName); category_ListBox.DataSource = categories; category_ListBox.DisplayMember = "CategoryName"; category_ListBox.SelectedIndex = -1; category_ListBox.SelectedIndexChanged += category_ListBox_SelectedIndexChanged; }