Git Product home page Git Product logo

downloader.net's Introduction

Downloader.NET

A simple high performance downloader for .NET with multi-chunk and bandwidth throttling support.

using Downloader;

const String url = "http://speedtest.newark.linode.com/100MB-newark.bin";
const String path = "result.mp4";
const String hash = "7b3d96bd611dd68a6d7e185dce41f46c8ec4b8e013dd27bb965931ffe917dfb2";

var downloader = new Downloader(url, path, new Settings
{
    ChunkCount = 8,
    BufferSize = 4096,
    MaximumBytesPerSecond = 0,
    RetryCount = 0,
    Timeout = 5000
});

downloader.OnProgress += chunks =>
{
    Console.WriteLine($"Thread {i} @ {chunk.Speed.ToMemoryMensurableUnit()}/s ({chunk.Progress:N2}%)");
};

downloader.OnComplete += async ex =>
{
    if (ex != null)
    {
        Console.WriteLine(ex.Message);
    }
	else
	{
		Console.WriteLine("Complete");
	}
};

await downloader.Download();

Console.WriteLine("Downloading");
Console.ReadKey();

The following settings can be passed to the constructor:

  • ChunkCount: Download a file with multiple threads to the server. The file will be split in equal parts.
  • BufferSize: The amount of data from the server to buffer and write to the file. Higher will be faster, but use more memory.
  • MaximumBytesPerSecond: Limit a single chunk with a maximum bytes per second.
  • RetryCount: Retry a chunk this many times before failing the download.
  • Timeout: When no data is received this amount of milliseconds, the download will error (or retry if RetryCount has not been reached yet).

downloader.net's People

Contributors

rogerfar avatar

Stargazers

Simon avatar genoher avatar  avatar  avatar  avatar โญ ๐Ÿพ avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.