private void OnDownloadStateChanged(DownloadStateChangedEventArgs e)
        {
            OnPropertyChanged(nameof(IsStartAll));
            if (e.NewState == DownloadStateEnum.Completed || e.NewState == DownloadStateEnum.Canceled)
            {
                OnDownloadCompletedOrCanceled(e);
            }

            if (e.NewState == DownloadStateEnum.Downloading)
            {
                var temp      = DownloadTaskList.FirstOrDefault(item => item.FileId == e.FileId);
                var indexThis = DownloadTaskList.IndexOf(temp);
                if (indexThis != 0)
                {
                    DownloadTaskList.Insert(0, temp);
                    DownloadTaskList.Remove(temp);
                }
            }
            Debug.WriteLine($"{DateTime.Now}: FileId={e.FileId}, OldState={e.OldState}, NewState={e.NewState}, IsStartAll={IsStartAll}");
        }
Example #2
0
        private void OnDownloadStateChanged(object sender, DownloadStateChangedEventArgs e)
        {
            RaisePropertyChanged(nameof(IsStartAll));
            if (e.NewState == DownloadStateEnum.Completed || e.NewState == DownloadStateEnum.Canceld)
            {
                OnDownloadCompletedOrCanceled(e);
            }

            if (e.NewState == DownloadStateEnum.Downloading)
            {
                var temp      = DownloadTaskList.FirstOrDefault(item => item.FileId == e.FileId);
                var indexThis = DownloadTaskList.IndexOf(temp);
                if (indexThis != 0)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        DownloadTaskList.Insert(0, temp);
                        DownloadTaskList.Remove(temp);
                    });
                }
            }
            Debug.WriteLine($"{DateTime.Now}: FileId={e.FileId}, OldState={e.OldState}, NewState={e.NewState}, IsStartAll={IsStartAll}");
        }