//load the query in a separate thread private Stream threadLoad(string query) { start_timer (); Stream stream = null; WebDownload downloader = new WebDownload (); bool finished = false; Thread thread = new Thread (delegate() { //catch any errors. ugly, but works. try { stream = downloader.ReadUrl (query); } catch { Application.Invoke (delegate{ fail_timer (); }); } finished = true; }); thread.Start (); //blocks the main thread waiting for the //downloading thread to finish. this keeps the //user interface responsive. while (!finished) while (Application.EventsPending ()) Application.RunIteration (); return stream; }