Click here to Skip to main content
15,897,226 members
Articles / Multimedia / GDI+

MyDownloader: A Multi-thread C# Segmented Download Manager

Rate me:
Please Sign up or sign in to vote.
4.95/5 (418 votes)
12 Feb 2008CPOL10 min read 2.2M   124.8K   1.3K  
Sample application that manages multiple segmented downloads and supports HTTP, FTP and YouTube video downloads
using System;
using System.Collections.Generic;
using System.Text;

namespace MyDownloader.Core
{
    #region ResolvingProtocolProviderEventArgs
    public class ResolvingProtocolProviderEventArgs : EventArgs
    {
        #region Fields

        private IProtocolProvider provider;
        private string url;

        #endregion

        #region Constructor

        public ResolvingProtocolProviderEventArgs(IProtocolProvider provider,
            string url)
        {
            this.url = url;
            this.provider = provider;
        }

        #endregion

        #region Properties

        public string URL
        {
            get { return url; }
        }

        public IProtocolProvider ProtocolProvider
        {
            get { return provider; }
            set { provider = value; }
        }

        #endregion
    } 
    #endregion

    #region DownloaderEventArgs
    public class DownloaderEventArgs : EventArgs
    {
        #region Fields

        private Downloader downloader;
        private bool willStart;

        #endregion

        #region Constructor

        public DownloaderEventArgs(Downloader download)
        {
            this.downloader = download;
        }

        public DownloaderEventArgs(Downloader download, bool willStart): this(download)
        {
            this.willStart = willStart;
        }

        #endregion

        #region Properties

        public Downloader Downloader
        {
            get { return downloader; }
        }

        public bool WillStart
        {
            get { return willStart; }
        }	

        #endregion
    } 
    #endregion

    #region SegmentEventArgs
    public class SegmentEventArgs : DownloaderEventArgs
    {
        #region Fields

        private Segment segment;

        #endregion

        #region Constructor

        public SegmentEventArgs(Downloader d, Segment segment)
            : base(d)
        {
            this.segment = segment;
        }

        #endregion

        #region Properties

        public Segment Segment
        {
            get { return segment; }
            set { segment = value; }
        }

        #endregion
    } 
    #endregion
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Brazil Brazil
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions