The answer to that tend to be determined on the user's internet connection. If you try to download too much too fast, you will peak, and drop then peak again and drop, ect. My suggestion is to allow the user to choose how many can be downloaded concurrently. The alternative is to just pick a number.
I would use ThreadPool.QueueUserWorkItem()<http://msdn.microsoft.com/en-us/library/kbf0f1ct.aspx> After the download is complete you can use the Invoke()<http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx>Method to call the UI thread. This could be a universal UpdateUI() method that actually removes the items from your internal list, and updates the UI. On Tue, Sep 2, 2008 at 4:52 AM, Mark <[EMAIL PROTECTED]> wrote: > > The user doesn't actually enter URLs of photos, but URLs of galleries > (or series of galleries)...and it's takes half a second to add them > (designed for ease of use)... so...the queue can get very large, very > fast. I know the code won't impose any limits on how many can be > asynchronously downloaded, but my question was more "is it efficient?" > -- ie, is it more efficient to download 10 photos, 2 at a time, or all > 10 photos at once? Maybe 2 at a time will achieve higher download > speeds and finish earlier? I assume IE and other browsers/programs > impose these limits for a reason. > > No, I havent looked into MSMQ, I'll have a look at that later. Thanks! > > On Sep 2, 1:06 am, CK <[EMAIL PROTECTED]> wrote: > > there is a limit in Internet Explorer, but using code you shouldn't > > have an issue. How quickly will users be able to enter a new url > > compared to how quickly the pictures are downloaded? > > > > Have you looked into MSMQ - Microsoft Message Queue? > > > > On 1 Sep, 09:58, Mark <[EMAIL PROTECTED]> wrote: > > > > > Isn't there a cap on how many images you can download at once? Most > > > downloader/uploader programs only download/upload 2-8 files at a > > > time...any more than that is inefficient/eats all your bandwidth, no? > > > I would like to DL about 8 at a time, and queue the rest... > > > > > On Aug 20, 12:40 am, CK <[EMAIL PROTECTED]> wrote: > > > > > > Why build a listbox full of the items? > > > > > > I would write my method for downloading the images, then create a > > > > delegate with a matching signature. Every time the user enters text > > > > and clicks the button, call the delegate asynchronously, passing in > > > > the string. This means each image will be downloaded asynchronously > > > > with no queuing mechanism required. > > > > > > On 19 Aug, 23:50, Mark <[EMAIL PROTECTED]> wrote: > > > > > > > I'm making a Windows Forms Application. It contains a ListView, a > > > > > TextBox and a Button. The user can type some stuff in the TextBox, > > > > > click the Button, and it will be added to the ListView. I want to > > > > > process the items in the ListView and then pop them off list, using > a > > > > > separate thread, so that the program doesn't hang and the user can > add > > > > > more items while it's running. With what I have right now, I can't > > > > > remove items from the list from a different thread. I understand > why > > > > > this causes problems, but I'm not sure how to fix it. I've tried > > > > > following a few tutorials to use delegates, but I can't seem to get > it > > > > > to work. Here's what I've got right now: > > > > > > > using System; > > > > > using System.Collections.Generic; > > > > > using System.ComponentModel; > > > > > using System.Data; > > > > > using System.Drawing; > > > > > using System.Text; > > > > > using System.Windows.Forms; > > > > > using System.Text.RegularExpressions; > > > > > using System.Threading; > > > > > > > namespace ImageDownloader > > > > > { > > > > > public partial class Form1 : Form > > > > > { > > > > > public Form1() > > > > > { > > > > > InitializeComponent(); > > > > > } > > > > > > > private void Download() > > > > > { > > > > > while (true) > > > > > { > > > > > if (listView1.Items.Count > 0) > > > > > { > > > > > listView1.Items.RemoveAt(0); > > > > > } > > > > > } > > > > > } > > > > > > > private void button1_Click(object sender, EventArgs e) > > > > > { > > > > > listView1.Items.Add(textBox1.Text); > > > > > textBox1.Text = ""; > > > > > } > > > > > > > private void Form1_Load(object sender, EventArgs e) > > > > > { > > > > > Thread t = new Thread(new ThreadStart(Download)); > > > > > t.Start(); > > > > > } > > > > > } > > > > > > > } > > > > > > > This theoretically should just remove all the items from the list > as > > > > > soon as they are added, one by one. Obviously I'll do some > processing > > > > > on each item first, but I need to get this working before I get > into > > > > > that :) > > > > > > > Thanks for any help.- Hide quoted text - > > > > > - Show quoted text - > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://cm.megasolutions.net/forums/default.aspx -~----------~----~----~----~------~----~------~--~---
