コード例 #1
0
        private async Task _Download()
        {
            while (_downBookSeries.Count > 0)
            {
                var item = _downBookSeries.First();

                if (item.Status != DownloadStatus.Waiting)
                {
                    continue;
                }
                item.Status = DownloadStatus.Downing;
                string SavePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "download", item.BookId);
                await _toolService.Download(item, SavePath, (down, e) =>
                {
                    item.Progress = e.ProgressPercentage;
                    _hubContext.Clients.All.SendAsync("downing", item);
                }, (down, e) =>
                {
                    item.Progress = 100;
                    item.Status   = DownloadStatus.Finished;
                    _hubContext.Clients.All.SendAsync("finished", item);
                    _downBookSeries.Remove(item);
                });

                await Task.Delay(1000);
            }
            IsRun = false;
        }