Пример #1
0
        /// <summary>
        /// Run the ebay request in the backgound
        /// </summary>
        public void Run()
        {
            for (; ;)
            {
                Api.Execute();
                if (Api.Error())
                {
                    String    ShortMessage = Xml.XPath.SelectSingleNode(Api.ResponseXml, "/*/Errors/ShortMessage");
                    Exception ex           = new Exception(ShortMessage);
                    throw ex;
                }
                dataStoreObject.Load(Api.ResponseXml);


                String TotalPages  = XPath.SelectSingleNode(Api.ResponseXml, "//PaginationResult/TotalNumberOfPages");
                String CurrentPage = XPath.SelectSingleNode(Api.ResponseXml, "//PageNumber");

                int nTotalPages  = Convert.ToInt16(TotalPages);
                int nCurrentPage = Convert.ToInt16(CurrentPage);

                if (false) // nCurrentPage > 0 && nCurrentPage < nTotalPages)
                {
                    // updateStatus("Moving to page (" + (++nCurrentPage).ToString() + " of " + nTotalPages + ")");
                    // progressBar1.Maximum = nTotalPages;
                    // progressBar1.Value = nCurrentPage - 1;

                    nCurrentPage++;
                    Api.innerNode["Pagination"]["PageNumber"].InnerText = nCurrentPage.ToString();
                }
                else
                {
                    // updateStatus("Retrieved all pages.");
                    break;
                }
            }

            // CompletedHandler(this, CompletedReturnObject);
            if (completed != null)
            {
                completed(this, dataStoreObject);
            }
        }
Пример #2
0
        // This event handler is where the actual,
        // potentially time-consuming work is done.
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;

            // Assign the result of the computation
            // to the Result property of the DoWorkEventArgs
            // object. This is will be available to the
            // RunWorkerCompleted eventhandler.
            Api.Execute();
            e.Result = Api.Result;
            // e.Result = Api.Result; //  "Hello"; // ComputeFibonacci((int)e.Argument, worker, e);
            // Completed(this, 1);
        }