service provider now uses a case-insensitive dictionary key, eliminating KeyNotFoundException errors

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@574 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2009-01-24 00:54:17 +00:00
parent 06ff604706
commit f327c2aa76
3 changed files with 28 additions and 3 deletions
@@ -215,6 +215,23 @@ namespace ProcessHacker
{
textDescription.Text = "";
}
try
{
using (ServiceController controller = new ServiceController(
listServices.SelectedItems[0].Name))
{
if (controller.DependentServices.Length == 0)
buttonDependents.Enabled = false;
if (controller.ServicesDependedOn.Length == 0)
buttonDependencies.Enabled = false;
}
}
catch
{
buttonDependents.Enabled = false;
buttonDependencies.Enabled = false;
}
}
catch (Exception ex)
{
+9 -1
View File
@@ -126,8 +126,16 @@ namespace ProcessHacker
/// Creates a new instance of the Provider class.
/// </summary>
public Provider()
: this(null)
{ }
/// <summary>
/// Creates a new instance of the Provider class, specifying a
/// custom equality comparer.
/// </summary>
public Provider(IEqualityComparer<TKey> comparer)
{
_dictionary = new Dictionary<TKey, TValue>();
_dictionary = new Dictionary<TKey, TValue>(comparer);
_thread = new Thread(new ThreadStart(Update));
_thread.SetApartmentState(ApartmentState.STA);
@@ -37,9 +37,9 @@ namespace ProcessHacker
public class ServiceProvider : Provider<string, ServiceItem>
{
public ServiceProvider()
: base()
: base(StringComparer.InvariantCultureIgnoreCase) // Windows is case-insensitive with services
{
this.ProviderUpdate += new ProviderUpdateOnce(UpdateOnce);
this.ProviderUpdate += new ProviderUpdateOnce(UpdateOnce);
}
public void UpdateServiceConfig(string name, Win32.QUERY_SERVICE_CONFIG config)