Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
修复下载逻辑bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Quanwei1992 committed Jan 18, 2017
1 parent cc0dc6e commit 5902881
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions KindleHelper/FormBookDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,40 +175,34 @@ private void backgroundworker_download_DoWork(object sender, DoWorkEventArgs e)
string savePath = e.Argument.ToString();
List<ChapterInfo> chaperInfoList = new List<ChapterInfo>();
for (int i = 0; i < chapters.Length; i++) {
if (backgroundworker_download.CancellationPending) return;
if (backgroundworker_download.CancellationPending) return;
var chapter = chapters[i];
float progress = (float)(i + 1) / (float)chapters.Length;
string info = string.Format("正在下载:{0} {1}/{2} {3:F2}%", chapter.title, i + 1, chapters.Length,
progress * 100);
backgroundworker_download.ReportProgress(i, info);

while (true)
{
while (true) {
bool downloadSucess = false;
for (int j = 0; j < 3; j++)
{
try
{
for (int j = 0; j < 3; j++) {
try {
var chapterInfo = LibZhuiShu.getChapter(chapter.link);
if (chapterInfo != null)
{
if (chapterInfo != null) {
chaperInfoList.Add(chapterInfo);
downloadSucess = true;
break;
}
}
catch (Exception exc){}
} catch (Exception exc) { }
}
if (!downloadSucess) {
var result = MessageBox.Show("章节 " + chapter.title + " 下载失败,是否重试?","下载失败",MessageBoxButtons.YesNo);
var result = MessageBox.Show("章节 " + chapter.title + " 下载失败,是否重试?", "下载失败", MessageBoxButtons.YesNo);
if (result != DialogResult.Yes) {
return;
}
}
} else {
break;
}
}



}
backgroundworker_download.ReportProgress(chapters.Length, "正在生成电子书请稍后....");
string ext = Path.GetExtension(savePath);
Expand Down

0 comments on commit 5902881

Please sign in to comment.