Exemplo n.º 1
0
        /// <summary>
        /// Pause all agent tasks safely.
        /// </summary>
        internal void Pause()
        {
            if (CurrentPacakge == null || CurrentPacakge.State != PackageState.Downloading)
            {
                return;
            }

            CurrentPacakge.State  = PackageState.Paused;
            ParentDownloder.State = DownloaderState.Paused;

            DownloadSpeedTracker.Stop();

            ParentDownloder.CallDownloadPause();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Resume all agent tasks safely.
        /// </summary>
        internal void Resume()
        {
            if (CurrentPacakge == null || CurrentPacakge.State != PackageState.Paused)
            {
                return;
            }

            CurrentPacakge.State  = PackageState.Downloading;
            ParentDownloder.State = DownloaderState.Resumed;

            DownloadSpeedTracker.Start();

            ParentDownloder.CallDownloadResume(CurrentPacakge);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Begin all agent tasks safely.
        /// </summary>
        internal async void Begin()
        {
            if (PackageList.Count == 0)
            {
                return;
            }

            System.Console.WriteLine("Devhus.Downloader is beginning...");
            State = AgentState.Busy;
            ParentDownloder.State = DownloaderState.Started;
            ParentDownloder.CallDownloadBegin();
            DownloadSpeedTracker.Start();

            await StartDownloading();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Stops all agent tasks safely.
        /// </summary>
        internal void Stop(bool forceStop = false)
        {
            if (forceStop == false)
            {
                if (CurrentPacakge == null ||
                    (CurrentPacakge.State != PackageState.Downloading && CurrentPacakge.State != PackageState.Paused))
                {
                    return;
                }
            }

            CurrentPacakge.State  = PackageState.Canceled;
            ParentDownloder.State = DownloaderState.Stopped;
            State = AgentState.Canceled;

            DownloadSpeedTracker.Stop();

            ParentDownloder.CallDownloadStop();
        }