コード例 #1
0
        /// <summary>
        /// Sample code to invoke the OrderFetcher.
        /// </summary>
        /// <param name="service">MarketplaceWebServiceOrders object.</param>
        /// <param name="sellerId">The seller Id.</param>
        /// <param name="marketplaceIdList">List of marketplaces passed in to the GetOrders call.</param>
        public static void InvokeOrderFetcherSample(MarketplaceWebServiceOrders service, string sellerId, string [] marketplaceIdList)
        {
            // Create a FetchOrderUpdates job with the default time span.
            FetchNewOrdersJob job = new FetchNewOrdersJob();
            job.isRunning = true;
            job.orderFetcher = new OrderFetcher(service, sellerId, marketplaceIdList);

            Thread jobThread = new Thread(job.OrdersJobThread);
            jobThread.IsBackground = true;
            jobThread.Start();

            // Pause on the main thread for one hour or until the thread exits, then end the job.
            jobThread.Join(1000 * 60 * 60);
            job.isRunning = false;

            // Block until the thread terminates to prevent any requests in progress from being aborted.
            while (jobThread.IsAlive)
            {
                Thread.Sleep(1000);
            }
        }
コード例 #2
0
        /// <summary>
        /// Sample code to invoke the OrderFetcher.
        /// </summary>
        /// <param name="service">MarketplaceWebServiceOrders object.</param>
        /// <param name="sellerId">The seller Id.</param>
        /// <param name="marketplaceIdList">List of marketplaces passed in to the GetOrders call.</param>
        public static void InvokeOrderFetcherSample(MarketplaceWebServiceOrders service, string sellerId, string [] marketplaceIdList)
        {
            // Create a FetchOrderUpdates job with the default time span.
            FetchNewOrdersJob job = new FetchNewOrdersJob();

            job.isRunning    = true;
            job.orderFetcher = new OrderFetcher(service, sellerId, marketplaceIdList);

            Thread jobThread = new Thread(job.OrdersJobThread);

            jobThread.IsBackground = true;
            jobThread.Start();

            // Pause on the main thread for one hour or until the thread exits, then end the job.
            jobThread.Join(1000 * 60 * 60);
            job.isRunning = false;

            // Block until the thread terminates to prevent any requests in progress from being aborted.
            while (jobThread.IsAlive)
            {
                Thread.Sleep(1000);
            }
        }