This Pull-Request will introduce the new submodule for replacing old HttpClientHelper and DownloadPartialAdapter with Hi3HelperCore.Http for more better multi-session download implementation and to fix Janky thread and file conflict issue caused by the old module.
The implementation for the Hi3HelperCore.Http is also more simple and straight forward without needing separate adapter (Unlike the old HttpClientHelper module).
The base implementation example of the module would be like this:
using System.Threading; // Import Threading for CancellationTokenSource
using System.Threading.Tasks; // Import Threading.Tasks for Task
using Hi3Helper.Http; // Import the Namespace for the module
CancellationTokenSource token = new(); // Initialize CancellationToken
// Do your download method here
public static async Task YourMethodHere()
{
byte Sessions = 4; // Set 4 Parallel Sessions
bool Overwrite = true; // Overwrite and don't continue if the previous session has been exist
Http client = new(); // Initialize Http module
// Do Multiple Session Download
await client.DownloadMultisession("https://yourURL.here/yourFile.here", @"C:\YourPath\YourOut.File", Overwrite, Sessions, token.Token);
// Merge Session Chunks After Download
await client.MergeMultisession(@"C:\YourPath\YourOut.File", Sessions, token.Token);
}
// Do your Cancel method here
public static void YourCancelHere() => this.token.Cancel();
Major Changes
Removal of HttpClientHelper and DownloadPartialAdapter classes.
Replacing DeleteExistingParallelDownloadFiles() to built-in DeleteMultisessionChunks() method for removing previous session chunks.
Some minor placement of some syntax to prevent conflict between pre-call of the Hi3HelperCore.Http methods.
The maximum of the parallel session has been decreased to 8 and the default value to be 4.
Changes In Action
As shown in this video, we could see that the Pause and Resume mechanism is now faster with no crash between the previous threads (thanks to the direct usage of the Hi3HelperCore.Http into the methods instead of bridging it from the DownloadPartialAdapter instead) while the progress also delayed for some moment to wait until all the sessions become ready.
Pull Request Overview
This Pull-Request will introduce the new submodule for replacing old
HttpClientHelper
andDownloadPartialAdapter
withHi3HelperCore.Http
for more better multi-session download implementation and to fix Janky thread and file conflict issue caused by the old module.The implementation for the
Hi3HelperCore.Http
is also more simple and straight forward without needing separate adapter (Unlike the oldHttpClientHelper
module). The base implementation example of the module would be like this:Major Changes
HttpClientHelper
andDownloadPartialAdapter
classes.Hi3HelperCore.Http
submodule for HTTP Download.Minor Changes
DeleteExistingParallelDownloadFiles()
to built-inDeleteMultisessionChunks()
method for removing previous session chunks.Hi3HelperCore.Http
methods.Changes In Action
As shown in this video, we could see that the Pause and Resume mechanism is now faster with no crash between the previous threads (thanks to the direct usage of the
Hi3HelperCore.Http
into the methods instead of bridging it from theDownloadPartialAdapter
instead) while the progress also delayed for some moment to wait until all the sessions become ready.