c# - DownloadFileAsync application not responding if file is over 500mb? -


so i'm using webclient.downloadfileasync(url, sfilepathtowritefileto); download file

url string url = "http://localhost/1.zip";

sfilepathtowritefileto root directory

whenever download 500mb zip archive, label1 goes berserk , says "downloading inf kb/s" , that's when starts not responding , crashes

label1 label1.text = string.format("downloading {0} kb/s", (e.bytesreceived / 1024d / sw.elapsed.totalseconds).tostring("0.00"));

it works fine when i'm downloading low size files, 20mb-50mb

oh btw, (i re-read post), sw stopwatch, incase wonder

what problem here, , how can solve it?

-- edit, added webclient:

using (webclient = new webclient())                 {                     webclient.downloadfilecompleted += new asynccompletedeventhandler(wzcompleted);                     webclient.downloadprogresschanged += new downloadprogresschangedeventhandler(wzprogresschanged);                     uri url = new uri(surltoreadfilefrom);                     sw.start();                     try                     {                         webclient.downloadfileasync(url, sfilepathtowritefileto);                     }                     catch (exception ex)                     {                         downloadinfo.text = ex.message;                     }                 } 

wzprogresschanged:

private void wzprogresschanged(object sender, downloadprogresschangedeventargs e)     {         statuscontent.text = "downloading new game files";         downloadinfo.text = "downloading: " + string.format("{0} mb / {1} mb", (e.bytesreceived / 1024d / 1024d).tostring("0.00"), (e.totalbytestoreceive / 1024d / 1024d).tostring("0.00")) + " " + string.format("{0} kb/s", (e.bytesreceived / 1024d / sw.elapsed.totalseconds).tostring("0.00")) + " (" + e.progresspercentage.tostring() + "%" + ")";         progressbar1.value = e.progresspercentage;     } 

wzcompleted: it's enabling 2 buttons , disabling 2 others, no need this?

in addition dkackman suggested, i'd suggest being bit more selective how update label , maybe put additional checking around values ensure don't values line nan/inf. see other posts here on around mean exactly. @ methods double.isinfinity determine if calc resulted in number can displayed or not.

also, of calculations outside of string format statement , based on findings, decide information provide user.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -