private void LoadPackagesBySpecifiedType(int type) { Text = "Loading..."; packagesListbox.Items.Clear(); pkgMap.Clear(); initialMap.Clear(); kw.Text = ""; string response; switch (type) { case THIRDPARTY_APPS: response = adbi.ListThirdPartyPackages(device); break; case DISABLED_APPS: response = adbi.ListDisabledPackages(device); break; case SYSTEM_APPS: response = adbi.ListSystemPackages(device); break; case ALL_APPS: response = adbi.ListPackages(device); break; default: throw new FormatException(); } using (StringReader sr = new StringReader(response)) { string line; int i = 0; while ((line = sr.ReadLine()) != null) { packagesListbox.Items.Add(line); pkgMap.Add(i, line); initialMap.Add(i, line); i++; } } Text = "Package Managment"; }