MultithreadDownloadLib 3.2.0

dotnet add package MultithreadDownloadLib --version 3.2.0
                    
NuGet\Install-Package MultithreadDownloadLib -Version 3.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MultithreadDownloadLib" Version="3.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MultithreadDownloadLib" Version="3.2.0" />
                    
Directory.Packages.props
<PackageReference Include="MultithreadDownloadLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MultithreadDownloadLib --version 3.2.0
                    
#r "nuget: MultithreadDownloadLib, 3.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MultithreadDownloadLib@3.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MultithreadDownloadLib&version=3.2.0
                    
Install as a Cake Addin
#tool nuget:?package=MultithreadDownloadLib&version=3.2.0
                    
Install as a Cake Tool

✨ MultithreadDownload

NuGet License: MIT .NET Version Build Status

MultithreadDownload 是一款基于多线程的高效文件下载库,支持分段并发下载,旨在提供稳定、可扩展的下载解决方案。当前版本仅支持 HTTP 协议。


目录


简介

MultithreadDownload 通过灵活的线程调度和任务管理,实现了高效且可扩展的文件下载。 项目采用 MIT 协议开源,已发布至 NuGet,方便集成与使用。


特点

  • 多线程分段下载 🚀:智能划分文件并发下载,显著提升下载速度。
  • 可扩展协议支持 🔌:提供统一接口,便于开发者自定义其他协议(FTP、BT等)。
  • 任务管理与调度 📦:基于任务队列和信号量机制,高效分配并控制并发任务数量。
  • 丰富的事件回调 🔔:支持进度更新、任务完成等事件通知。
  • 规划中功能 🛠️:
    • 多协议支持(FTP / BitTorrent 等)
    • 断点续传(Resume Download)
    • 更完善的错误处理与恢复机制

安装

通过 NuGet 快速安装:

dotnet add package MultithreadDownloadLib

或在 Visual Studio 的 NuGet 管理器中搜索 MultithreadDownloadLib 进行安装。


使用示例

以下示例展示了如何使用 HTTP 协议进行多线程文件下载:

using MultithreadDownload.Core;
using MultithreadDownload.Protocols;
using MultithreadDownload.Protocols.Http;
using MultithreadDownload.Tasks;

byte MAX_PARALLEL_THREADS = 8;
byte MAX_PARALLEL_TASKS = 3;

// 创建下载服务管理器(当前使用 HTTP 协议)
var downloadManager = new MultiDownload(MAX_PARALLEL_TASKS, DownloadServiceType.Http);

// 获取下载任务上下文(包括分段信息等)
var context = await HttpDownloadContext.GetDownloadContext(MAX_PARALLEL_THREADS, Path.GetTempPath(), "https://example.com/file.zip");

// 添加下载任务到管理器
downloadManager.AddTask(context.Value.UnwrapOrThrow("Cannot get the context."));

// 启动任务分配器,自动管理任务并启动下载
downloadManager.StartAllocator();

// (可选)监听任务完成事件
downloadManager.TasksProgressCompleted += (sender, e) =>
{
    Console.WriteLine("Task completed.");
};

// (可选)监听下载速度变化
downloadManager.GetDownloadTasks()[0].SpeedTracker.SpeedReportGenerated += (e) =>
{
    Console.WriteLine($"Current speed: {e}");
};

功能状态

功能 状态
多线程 HTTP 下载 ✅ 已完成
FTP 支持 🔧 开发中
BitTorrent 支持 🔧 开发中
断点续传 🔧 规划中
错误重试和处理 ✅ 已完成
还有更多... ...

在提供正确的 HTTP 链接、有效的参数及稳定的网络环境下,当前版本能够稳定运行,不存在已知运行时异常。


支持的环境

  • .NET 6 / .NET 7 / .NET 8 / .NET 9
  • Windows / Linux / macOS

贡献

欢迎任何形式的贡献,包括但不限于:

  • 提交 Issue 或 Bug 报告 🐛
  • 提出功能建议或优化意见 💡
  • 提交 Pull Request ✍️

如需进行重大修改,请提前通过 Issue 讨论,确保开发方向一致。


许可证

本项目遵循 MIT License。 您可以自由地使用、修改、分发本项目代码,仅需保留原作者声明。

依赖声明

本项目在测试阶段使用了以下第三方库:

  • Fluent Assertions - 用于增强单元测试的可读性。根据 Xceed Software Inc. 的社区许可协议 (Community License Agreement),该库仅用于本项目的非商业性测试用途,并未进行与其他产品的性能对比测试,也未公开发布任何基准测试结果。

MultithreadDownload —— 致力于构建下一代多线程下载解决方案!🚀 如果你喜欢这个项目,欢迎 ⭐Star 和 🍴Fork!

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.0 178 9/28/2025
3.1.2 159 5/23/2025
3.1.1 188 5/11/2025
3.1.0 196 5/7/2025
3.0.0 201 5/1/2025