private void MySearchCallbackTimeout(object state, bool timedOut)
        {
            // Create an EventHandler delegate.
            UpdateSearchButtonHandler updateSearch = new UpdateSearchButtonHandler(UpdateSearchButtonEvent);

            // Invoke the delegate on the UI thread.
            this.Invoke(updateSearch, new object[] { new BoolArgs(true) });

            if (timedOut)
            {
                RequestState reqState = (RequestState)state;
                if (reqState != null)
                {
                    reqState.Request.Abort();
                    reqState.Request = null;
                }
                MessageBox.Show("Request timed out.", "Connection Error", MessageBoxButtons.OK);
                toolStripStatusLabel1.Text = "Search failed.";
                searchButton.Enabled       = true;
                if (currentResultPage < totalResultPages)
                {
                    moreButton.Show();
                }
            }
        }
        private void MySearchCallback(IAsyncResult result)
        {
            // Create an EventHandler delegate.
            UpdateSearchButtonHandler updateSearch = new UpdateSearchButtonHandler(UpdateSearchButtonEvent);

            // Invoke the delegate on the UI thread.
            this.Invoke(updateSearch, new object[] { new BoolArgs(true) });
            RequestState rs = (RequestState)result.AsyncState;

            try {
                // Get the WebRequest from RequestState.
                WebRequest req = rs.Request;

                // Call EndGetResponse, which produces the WebResponse object
                //  that came from the request issued above.
                WebResponse resp = req.EndGetResponse(result);

                //  Start reading data from the response stream.
                System.IO.Stream responseStream = resp.GetResponseStream();

                // Store the response stream in RequestState to read
                // the stream asynchronously.
                rs.ResponseStream = responseStream;
                xmlReader         = new System.Xml.XmlTextReader(responseStream);
                xmlDoc            = new System.Xml.XmlDocument();
                xmlDoc.Load(xmlReader);
                xmlReader.Close();
                resp.Close();
                req = null;
            } catch (WebException we) {
                rs.Request.Abort();
                rs.Request = null;
                toolStripStatusLabel1.Text = "Search failed.";
                MessageBox.Show(we.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (currentResultPage < totalResultPages)
                {
                    moreButton.Show();
                }

                return;
            }

            int nResults = Convert.ToInt32(xmlDoc.GetElementsByTagName("numResults")[0].InnerText);

            if (nResults > 0)
            {
                totalResultPages           = nResults / 20 + 1;
                toolStripStatusLabel1.Text = "Items found: " + nResults;
                toolStripStatusLabel2.Text = "Showing page " + currentResultPage.ToString() + " of " + totalResultPages.ToString();
            }
            else
            {
                MessageBox.Show("Your query didn't return any results from Infoseek.\nTry some other search term or regular Infoseek\nwildcards like '*', '?', '^'", "No match", MessageBoxButtons.OK, MessageBoxIcon.Information);
                toolStripStatusLabel1.Text = "Ready";
                toolStripStatusLabel2.Text = "";
                return;
            }
            System.Xml.XmlNodeList memberNodes = xmlDoc.SelectNodes("//result");
            foreach (System.Xml.XmlNode node in memberNodes)
            {
                InfoseekResult ir        = new InfoseekResult();
                ProgramTitle   progTitle = new ProgramTitle();
                ir.InfoseekID  = node.SelectSingleNode("id").InnerText;
                ir.ProgramName = node.SelectSingleNode("title").InnerText;
                ir.Year        = node.SelectSingleNode("year").InnerText;
                ir.Publisher   = node.SelectSingleNode("publisher").InnerText;
                ir.ProgramType = node.SelectSingleNode("type").InnerText;
                ir.Language    = node.SelectSingleNode("language").InnerText;
                ir.Score       = node.SelectSingleNode("score").InnerText;
                ir.PicInlayURL = node.SelectSingleNode("picInlay").InnerText;
                infoList.Add(ir);
                progTitle.Title = ir.ProgramName;
                // ProgramTitleList.Add(progTitle);
                AddItemToListBox(infoListBox, infoList.Count - 1, ir.ProgramName,
                                 ir.PicInlayURL, ir.Publisher, ir.ProgramType,
                                 ir.Year, ir.Language, ir.Score);
            }
        }