c# - Downloading more files from URLs paralell -
c# - Downloading more files from URLs paralell -
in datagrindview row have got lots of urls.
i want download thew files urls
at utilize code.:
int rowcount = datagridview1.rows.count; (int = 0; < rowcount; i++) { string filename = patch; webclient webc = new webclient(); webc.downloadfile(datagridview1.rows[i].cells[0].value.tostring(), patch + "\\" + "alap" + (i+1).tostring() + ".mp4"); }
and working my, download files 1 one.
i download files paralell (multithread), illustration 5 files download in same time.
try:
int rowcount = datagridview1.rows.count; list<task> tasks = new list<task>() (int = 0; < rowcount; i++) { string filename = patch; var tsk = task.factory.startnew(() => { seek { var integerstring = (i+1).tostring(); webclient webc = new webclient(); webc.downloadfile(datagridview1.rows[i].cells[0].value.tostring(), patch + "\\" + "alap" + integestring + ".mp4"); } grab { //log } }); tasks.add(tsk); } task.waitall(tasks.toarray());
c# multithreading download
Comments
Post a Comment