Beispiel #1
0
        public void stashFinishedProcessing(object sender, StashProcessingFinishedEventArgs e)
        {
            ArrayList tempStashList = ArrayList.Synchronized(stashList);

            if (!tempStashList.Contains(e.theStash.id))
            {
                poe_logger.logError("The ID that ended did not exist in the array list, retrying...: " + e.theStash.id);
                for (int x = 0; x <= 5; x++)
                {
                    if (stashList.Contains(e.theStash.id))
                    {
                        break;
                    }
                    else
                    {
                        poe_logger.logError("Still don't see ID in arraylist");
                    }
                }
            }
            lock (stashList.SyncRoot) { stashList.Remove(e.theStash.id); }
            if (stashList.Count == 0 && doneQueuing)
            {
                ChangeProcessingFinishedEventArgs a = new ChangeProcessingFinishedEventArgs();
                a.theThread = Thread.CurrentThread;
                a.theChange = this;
                poe_logger.logInfo("Calling Change Process Finished");
                complete();
                OnChangeProcessingFinished(a);
            }
            else
            {
                ignoredStashes++;
            }
            e.theStash.Dispose();
        }
Beispiel #2
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);
        }
Beispiel #3
0
        protected virtual void OnChangeProcessingFinished(ChangeProcessingFinishedEventArgs e)
        {
            EventHandler <ChangeProcessingFinishedEventArgs> handler = changeProcessingFinished;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #4
0
        public void changeFinishedProcessing(object sender, ChangeProcessingFinishedEventArgs e)
        {
            //e.theChange.insert();
            poe_logger.logInfo("Finished processing change ID: " + e.theChange.next_change_id);
            Console.WriteLine("Finished processing change ID: " + e.theChange.next_change_id);
            lock (changeList.SyncRoot) { changeList.Remove(e.theThread); }

            e.theChange.Dispose();
            //e.theThread.Abort();
            //Console.WriteLine("Thread Count: " + threadList.Count);

            //if (keepRunning)
            //processPoeUpdate();
        }