/// <summary>Begins a search on the given key server for the given search terms.</summary> public void BeginSearch(string terms, Uri keyServer) { if(terms == null || keyServer == null) throw new ArgumentNullException(); if(PGP == null) throw new InvalidOperationException("The PGP property is not set."); if(TaskInProgress) throw new InvalidOperationException("A search or import is in progress."); terms = terms.Trim(); if(string.IsNullOrEmpty(terms)) throw new ArgumentException("No search terms were provided."); progressBar.Style = ProgressBarStyle.Marquee; results.Items.Clear(); searchServer = keyServer; // save the server used for the search so we know from what server to import the keys thread = new Thread(delegate() { try { PGP.FindKeysOnServer(keyServer, GotResults, terms.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); Invoke((ThreadStart)delegate { SearchSucceeded(); }); } catch(Exception ex) { Invoke((ThreadStart)delegate { SearchFailed(ex); }); } }); UpdateButtons(); thread.Start(); }