/// <summary> /// Default implementation will search in the App.config. Ovveride this in order to read the names of the processes that /// you want to monitor from a custom source. /// You can read them from any source, as long as you inititialize the BasicProcessList member /// </summary> /// <exception cref="ApplicationException">If there are errors while performing this operation</exception> protected virtual void ReadProcessNamesThatNeedToBeMonitored() { const string NB_KEY = "PMonitorNbOfProcesses"; const string PROCESS_BASE_NAME_KEY = "PMonitorProcess"; try { int nbProcessesToMonitor = Int32.Parse(ConfigurationManager.AppSettings[NB_KEY]); for (int i = 1; i <= nbProcessesToMonitor; i++) { string processName = ConfigurationManager.AppSettings[PROCESS_BASE_NAME_KEY + i].Split(',').ElementAt(0); string processFriendlyName = ConfigurationManager.AppSettings[PROCESS_BASE_NAME_KEY + i].Split(',').ElementAt(1); BasicProcessList.Add(new BasicProcessInformation(processName, processFriendlyName)); } } catch (Exception ex) { throw new ApplicationException("Error while reading the process names from the App.config file.", ex); } }
protected override void ReadProcessNamesThatNeedToBeMonitored() { BasicProcessList.Add(new BasicProcessInformation("notepad", "Notepad")); }