private void continuousSearch()
{
// The sprinkled thread sleeps is for mono 3.x
// winforms stuff freaking out
while (_runSearch) {
if (_lastKeypress.AddMilliseconds(400) > DateTime.Now || _searchTerms.Count == 0) {
System.Threading.Thread.Sleep(50);
continue;
}
var searchText = "";
while (_searchTerms.Count > 0) {
searchText = _searchTerms.Dequeue();
}
try
{
var items = _cache.Find(searchText).Take(30).ToList();
if (items.Count > 30)
items = items.GetRange(0, 30);
_syncContext.Post(nothing => informationList.Items.Clear(), null);
foreach (var item in items) {
_syncContext.Post(itm => addItem((ICodeReference)itm), item);
}
_syncContext.Post(nothing => {
if (informationList.Items.Count > 0)
informationList.Items[0].Selected = true;
informationList.Refresh();
}, items);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}