Skip to content

Commit

Permalink
Finish implementation of DownloadManager.Clear()
Browse files Browse the repository at this point in the history
  • Loading branch information
Issung committed Oct 22, 2023
1 parent 02fcde0 commit 82f0ac3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion GChan/Controllers/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Cancel()
}

/// <summary>
/// Cancel and dispose of download.
/// Cancel download and dispose resources.
/// </summary>
public void Dispose()
{
Expand Down
8 changes: 8 additions & 0 deletions GChan/Controllers/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,16 @@ public void Cancel(Func<T, bool> predicate)
}
}

/// <summary>
/// Clear the entire download manager (waiting and currently downloading), and cancel those that were in progress.
/// </summary>
public void Clear()
{
while (waiting.Count > 0)
{
waiting.TryDequeue(out _);
}

while (downloading.Count > 0)
{
var kvp = downloading.FirstOrDefault();
Expand Down
3 changes: 2 additions & 1 deletion GChan/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
// TODO: #41 - Cancellation currently not working, implement later.
//if (!Settings.Default.SaveHTML)
//{
// // Clear all downloads on main controller threadHtmlDownloader.
// Clear all downloads on main controller threadHtmlDownloader.
// threadHtmlDownloader.Clear();
//}

systemTrayNotifyIcon.Visible = Settings.Default.MinimizeToTray;
Expand Down

0 comments on commit 82f0ac3

Please sign in to comment.