Пример #1
0
        public void OnStatusChenged(Download d, EDownloadStatus oldstatus, EDownloadStatus newstatus)
        {
            if (Deserializing) return;

            if (MainForm != null &&
                !MainForm.Disposing &&
                !MainForm.IsDisposed &&
                MainForm.InvokeRequired)
            {
                try
                {
                    MainForm.Invoke((Action<Download, EDownloadStatus, EDownloadStatus>)OnStatusChengedA,
                        new object[] { d, oldstatus, newstatus });
                }
                catch (Exception) { }
            }
            else
                OnStatusChengedA(d, oldstatus, newstatus);
        }
Пример #2
0
        public void OnStatusChengedA(Download d, EDownloadStatus oldstatus, EDownloadStatus newstatus)
        {
            if (Deserializing) return;

            if (newstatus == EDownloadStatus.Running)
            {
                if (RunningDownloads.Contains(d)) return;
                RunningDownloads.Add(d);
                DownloaderState = EDownloaderState.Running;
            }
            else if (newstatus == EDownloadStatus.Completed)
            {
                if (!RunningDownloads.Contains(d)) return;
                RunningDownloads.Remove(d);
                if (IsCompleted())
                    OnAllompleted();
                else if (RunningDownloads.Count < MaxParalelDownloads)
                    StartNext();
            }
            else if (newstatus == EDownloadStatus.Stopped)
            {
                if (!RunningDownloads.Contains(d)) return;
                RunningDownloads.Remove(d);

                if (d.Reseting)
                    d.ResetA();

                if (d.Removing)
                    d.RemoveA();

                if(DownloaderState == EDownloaderState.Stopping)
                {
                    if(RunningDownloads.Count == 0)
                        DownloaderState = EDownloaderState.Stopped;
                }
                else if (DownloaderState == EDownloaderState.Running)
                {
                    if (IsCompleted())
                        OnAllompleted();
                    else if (RunningDownloads.Count < MaxParalelDownloads)
                        StartNext();
                }
            }
            else if (newstatus == EDownloadStatus.Error)
            {
                if (!RunningDownloads.Contains(d)) return;
                RunningDownloads.Remove(d);
                if (DownloaderState == EDownloaderState.Stopping)
                {
                    if (RunningDownloads.Count == 0)
                        DownloaderState = EDownloaderState.Stopped;
                }
                else if (DownloaderState == EDownloaderState.Running)
                {
                    if (IsCompleted())
                        OnAllompleted();
                    else if (RunningDownloads.Count < MaxParalelDownloads)
                        StartNext();
                }
            }
        }
Пример #3
0
 public StatusChengeEventArgs(EDownloadStatus oldstatus, EDownloadStatus newstatus)
 {
     OldStatus = oldstatus;
     NewStatus = newstatus;
 }