private void LoadKeys(string keyPart, string valuePart) { try { Cursor = Cursors.WaitCursor; keyItemBindingSource.DataSource = null; lblKeyCount.Text = "0 items"; if (_connectionString.IsSpecified()) { using (var redis = new RedisService(_connectionString)) { IList <string> keys; if (keyPart.IsSpecified()) { keys = redis.FindByKey(keyPart).Result.ToList(); } else if (valuePart.IsSpecified()) { keys = redis.FindByValue(valuePart).Result; } else { keys = redis.GetAllKeys(); } var keyItems = keys.Select(x => new KeyItem(x)).OrderBy(x => x.Key).ToList(); lblKeyCount.Text = $"{keyItems.Count} items"; keyItemBindingSource.DataSource = keyItems; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "LoadKeys", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor = Cursors.Default; } }