Hello, I am working on a WPF platform oriented to the .NET framework 4.5.2. I am writing a bootloader for my application. Here is the 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;
Now I want the button to pause the download, and with the other button, click the "Download" button to resume the download. I tried working with the .set() property of the AutoReset event and the .Reset() tag, but that didn't work. I need help. My button code:
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 also tried this link. How to pause / pause a stream and then continue? . Nothing happens
I also went through Adding a pause and continuing to work in my bootloader , but I was not able to include the solution in my code above, as I am also updating the boot process in the user interface.
user5130773
source share