Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1071149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:40:23+00:00 2026-05-16T20:40:23+00:00

In our application we need to import transaction data from paypal through an API

  • 0

In our application we need to import transaction data from paypal through an API for the users of my application and store in the database. I’ve thousands (approx 5k now) of users and it is increasing day by day.

This application is a .net windows service.

This imports data on hourly basis for all the users. At present we are importing data for users one user after the other, but sometimes what happens one user data may be so large that it takes around 5hrs to get his entire data, so we are blocking other users till this user data import is finished. This hourly import for all the other users completely gone for a toss.

To avoid this we thought of creating threads for each user import and run them every hour using windows service. Here we have a situation where we need to think about bandwidth at any point of time as all the threads will start at the same time. Is this an issue at all?

Now, I want to know whether our new implementation is right way or not? Also I want to know how it is done usually? If anyone has come across this kind of functionality then please let us know how it is done.

If my question is not clear enough please let me know I’ll provide more info.

Edit: If I send so many requests to Paypal from a single IP, how does it handle it? Any idea whether it is limiting requests per IP?

Update: Thanks for all the suggestions and feedback.

I thought of using jgauffin’s solution as it was perfect mimic of ThreadPool. But here I need some more features like changing thread limit dynamically and recursive calling of call back method.

After lot of research and analysing thread pool, I’ve decided to use SmartThreadPool which is made based on threadpool logic but with more features. It is quite good and serving my purpose perfectly.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:40:24+00:00Added an answer on May 16, 2026 at 8:40 pm

    I would use a queue and let’s say five threads for this. Each time a thread is is completed it will get a new user from the queue.

    Example code:

    public class Example
    {
    
        public static void Main(string[] argv)
        {
            //setup
            DownloadQueue personQueue = new DownloadQueue();
            personQueue.JobTriggered += OnHandlePerson;
            personQueue.ThreadLimit = 10; //can be changed at any time and will be adjusted when a job completed (or a new one is enqueued)
    
            // enqueue as many persons as you like
            personQueue.Enqueue(new Person());
    
            Console.ReadLine();
        }
    
        public static void OnHandlePerson(object source, PersonEventArgs e)
        {
            //download persno here.
        }
    }
    
    public class DownloadQueue
    {
        Queue<Person> _queue = new Queue<Person>();
        int _runningThreads = 0;
    
        public int ThreadLimit { get; set; }
    
        /// <summary>
        /// Enqueue a new user.
        /// </summary>
        /// <param name="person"></param>
        public void Enqueue(Person person)
        {
            lock (_queue)
            {
                _queue.Enqueue(person);
                if (_runningThreads < ThreadLimit)
                    ThreadPool.QueueUserWorkItem(DownloadUser);
            }
        }
    
        /// <summary>
        /// Running using a ThreadPool thread.
        /// </summary>
        /// <param name="state"></param>
        private void DownloadUser(object state)
        {
            lock (_queue)
                ++_runningThreads;
    
            while (true)
            {
                Person person;
                lock (_queue)
                {
                    if (_queue.Count == 0)
                    {
                        --_runningThreads;
                        return; // nothing more in the queue. Lets exit
                    }
                    person = _queue.Dequeue();
                }
    
                JobTriggered(this, new PersonEventArgs(person));
            }
        }
    
        public event EventHandler<PersonEventArgs> JobTriggered = delegate { };
    }
    
    
    public class PersonEventArgs : EventArgs
    {
        Person _person;
    
        public PersonEventArgs(Person person)
        {
            _person = person;
        }
    
        public Person Person { get { return _person; } }
    }
    public class Person
    {
        public Person(string fName, string lName)
        {
            this.firstName = fName;
            this.lastName = lName;
        }
    
        public string firstName;
        public string lastName;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application which we need to allow users from our customer's systems
The application I am working inputs lot of data from file import and updates
To implement data access code in our application we need some framework to wrap
Our application has a need to share an existing database table with another locally
[edit] We're collecting credit application data from users on a web form. I have
My question is when I click the Exit button through our application It need
As a part of our application I need to write simple workflow system which
In our enterprise application we need to attach files to a document. We have
In our wicket application I need to start a long-running operation. It will communicate
I need to separate our application into a light-weight gui application and a business

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.