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 6558275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:10:46+00:00 2026-05-25T13:10:46+00:00

I need to download certain files using FTP.Already it is implemented without using the

  • 0

I need to download certain files using http://FTP.Already it is implemented without using the thread. It takes too much time to download all the files.
So i need to use some thread for speed up the process .

my code is like

  foreach (string str1 in files)
   {
      download_FTP(str1)
   }

I refer this , But i don’t want every files to be queued at ones.say for example 5 files at a time.

  • 1 1 Answer
  • 0 Views
  • 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-25T13:10:47+00:00Added an answer on May 25, 2026 at 1:10 pm

    Okay, as you’re not using .NET 4 that makes it slightly harder – the Task Parallel Library would make it really easy to create five threads reading from a producer/consumer queue. However, it still won’t be too hard.

    • Create a Queue<string> with all the files you want to download
    • Create 5 threads, each of which has a reference to the queue
    • Make each thread loop, taking an item off the queue and downloading it, or finishing if the queue is empty

    Note that as Queue<T> isn’t thread-safe, you’ll need to lock to make sure that only one thread tries to fetch an item from the queue at a time:

    string fileToDownload = null;
    lock(padlock)
    {
        if (queue.Count == 0)
        {
            return; // Done
        }
        fileToDownload = queue.Dequeue();
    }
    

    As noted elsewhere, threading may not speed things up at all – it depends where the bottleneck is. If the bottleneck is the user’s network connection, you won’t be able to get more data down the same size of pipe just by using multi-threading. On the other hand, if you have a lot of small files to download from different hosts, then it may be latency rather than bandwidth which is the problem, in which case threading will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to download a text file from the internet using C#. The file
I need to track the download of a certain iphone application. I tried a
I have an iOS app, and at certain times I need to download a
I need download some html content (pages) made for iphone (or mobile devices) using
I'm making an Android app where the user can download files from a FTP-server.
I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk.
I need customers to be able to download PDFs of letters that have been
I have a need to allow for a user to download an event that
Quick (and hopefully easy) question: I need to trigger a download of a PDF
In C#, if I need to open an HTTP connection, download XML and get

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.