多文件下载器 [英] Multi file downloader

查看:106
本文介绍了多文件下载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个小的游戏启动板,以便当您单击更新"按钮时,它将下载50多个游戏相关文件(位于我的Web服务器上),我没有包含在安装程序中,并使用当前正在下载的文件名.有没有一种简单的方法可以编写这样的代码? (与C#相比仍然显得有些笨拙)

Im developing a small game launchpad so that when you hit the "Update" button it will download the 50+ game dependency files (That are on my Web server) i didn''t include in the installer and update a label with the current file name being downloaded. is there an easy way to code something like this in? (Still rather noobish with C#)

推荐答案

如果它们托管在标准Web服务器上,则可以启动多个WebRequests(或FtpWebRequests,如果它们位于FTP服务器).我建议将所有文件名放在一个共享队列中,并具有一个或多个(大约4个)工作线程,这些工作线程反复从队列中删除一项,创建并运行下载请求,直到没有剩余.这些工作人员可以触发UI可以选择更新显示的事件.

您需要多个线程,因为在不使用带宽的情况下,在一个请求完成和下一个请求开始之间始终会浪费时间.在FTP客户端中,默认值介于2到5之间,这似乎是相似的要求.
If they''re hosted on a standard web server you can start multiple WebRequests (or FtpWebRequests, if they''re on an FTP server). I recommend putting all the file names onto a shared queue and having one or more (probably about 4) worker threads that repeatedly take an item off the queue, create and run a download request until there are none left. Those workers can fire events that the UI can pick up to update a display.

You want more than one thread because otherwise there is always wasted time in between one request finishing and the next starting when your bandwidth is not being used. Somewhere between 2 and 5 seems to be the default in FTP clients which have a similar requirement.


这篇关于多文件下载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆