Exemple #1
0
        public void Process()
        {
            inProgress();
            Console.WriteLine("starting processing change: " + this.next_change_id);
            poe_logger.logInfo("Start processing change: " + this.next_change_id);
            if (this.stashes.Count == 0)
            {
                poe_logger.logError("The stash count was 0");
            }

            TaskScheduler           myScheduler = TaskScheduler.Default;
            TaskFactory             factory     = new TaskFactory(myScheduler);
            CancellationTokenSource cts         = new CancellationTokenSource();
            List <Task>             tasks       = new List <Task>();

            for (int i = 0; i < this.stashes.Count; i++)
            {
                poe_stash myStash = this.stashes[i];
                if (myStash.Public && myStash.stashType == "PremiumStash")
                {
                    Task t = factory.StartNew(() =>
                    {
                        myStash.changeId = this.changeId;
                        myStash.addStash();
                    }, cts.Token);
                    tasks.Add(t);

                    /*processedStashes++;
                     * myStash.changeId = this.changeId;
                     * lock (stashList.SyncRoot) { stashList.Add(myStash.id); }
                     * if (!stashList.Contains(myStash.id))
                     *  //poe_logger.logError("Failure to add to stash list: " + myStash.id);
                     *  Console.WriteLine("Failure to add to stash list: " + myStash.id);
                     * Thread stashThread = new Thread(new ThreadStart(myStash.addStash));
                     * myStash.stashProcessingFinished += stashFinishedProcessing;
                     * //lock (stashList.SyncRoot) { stashList.Add(stashThread); }
                     * stashThread.Start();
                     * //myStash.addStash();*/
                }

                /*if (!keepRunning)
                 * {
                 *  break;
                 * }*/
                //Thread.Sleep(10);
            }

            Task.WaitAll(tasks.ToArray());
            cts.Dispose();

            doneQueuing = true;
            ChangeProcessingFinishedEventArgs a = new ChangeProcessingFinishedEventArgs();

            a.theThread = Thread.CurrentThread;
            a.theChange = this;
            poe_logger.logInfo("Calling Change Process Finished");
            complete();
            OnChangeProcessingFinished(a);
        }
 private void processStash(poe_stash myStash)
 {
     if (myStash.Public)
     {
         myStash.addStash();
         myBw.ReportProgress(0, "Stash ID: " + myStash.id);
     }
 }