hello working on wpf platform targeting .net framework 4.5.2. writing downloader application. here code:
private void download(dictionary<int, fileandlinkclass> mylinks) { applicationdownloadthread = new thread(() => { foreach (keyvaluepair<int, fileandlinkclass> item in mylinks) { fileno++; webclient mywebclient = new webclient(); mywebclient.downloadprogresschanged += mywebclient_downloadprogresschanged; mywebclient.downloadfilecompleted += mywebclient_downloadfilecompleted; // download web resource , save current filesystem folder. string downloadedfileadress = system.io.path.combine(filelocation, $"{item.value.filename}"); mywebclient.downloadfileasync(new uri(item.value.link), downloadedfileadress); while (mywebclient.isbusy) { } } }); applicationdownloadthread.isbackground = false; applicationdownloadthread.start(); //unzipandcreateupdatepackage(mylinks); }
now want @ button click download must paused , @ button click download must resumed. tried working .set()
property of autoreset event , .reset()
property of same didn't work. need help. button click code are:
private autoresetevent waithandle = new autoresetevent(true); private void startdownloadbtn_click(object sender, routedeventargs e) { waithandle.set(); } private void stopdownloadbtn_click(object sender, routedeventargs e) { waithandle.reset(); }
i have tried link how pause/suspend thread continue it?. nothing happens
i've gone through adding pause , continue ability in downloader failed incorporate solution in above code updating download progress on ui.
well did more digging, apparently if adding pause , continue ability in downloader wasn't clear uses byte stream data in class. maybe check out link below, provides vs solution on wpf downloading .zip file extensions pause/resume/stop capabilities. please let me know if need more help.
link codeproject article: c# .net background file downloader
Comments
Post a Comment