Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multi-threaded downloading
#1
Could you create a class or function for multi-threaded downloading? Similar to the code below.

This is very time-saving when downloading large files.

Or how to implement similar functionality simply in LA?
Thanks in advance!
 
C# class reference code link:
nuget -\Masuit.Tools.Core;
https://github.com/ldqk/Masuit.Tools/blo...nloader.cs
 
Code:
Copy      Help
using Masuit.Tools.Net;

var mtd = new MultiThreadDownloader("http://storage.live.com/items/A93A8C276E440EC0!590:/wps2019.exe?authkey=!AJCW6xXpJYK9QjE", Environment.GetEnvironmentVariable("temp"), @"C:\wps.exe", 8);
mtd.Configure(req =>
{
    req.Referer = "https://masuit.com";
    req.Headers.Add("Origin", "https://baidu.com");
});
mtd.TotalProgressChanged += (sender, e) =>
{
    var downloader = sender as MultiThreadDownloader;
    Console.WriteLine("Download progress: " + downloader.TotalProgress + "%");
    Console.WriteLine("Download speed: " + downloader.TotalSpeedInBytes / 1024 / 1024 + " MBps");
};
mtd.FileMergeProgressChanged += (sender, e) =>
{
    Console.WriteLine("Download complete");
};
mtd.FileMergedComplete += (sender, e) =>
{
    Console.WriteLine("File merge complete");
};
mtd.Start(); // Start download
             //mtd.Pause(); // Pause download
             //mtd.Resume(); // Resume download
#2
Try https://github.com/bezzad/Downloader
#3
Thank you for sharing.
I have another question:
Using the code from #1, there is no response when executed in LA, but it works correctly in LP.
I've encountered similar issues before, and I don't know what might be causing this.
#4
I guess the program must not exit after calling Start.
#5
I checked the process but didn't find anything...  
In this situation, it would be great if LA could provide some hints.  
I often encounter this issue where everything works fine in LP, but in LA, sometimes adding `.result` or `await` helps, but sometimes it still doesn't work.


Forum Jump:


Users browsing this thread: 3 Guest(s)