Doing this with threads
This commit is contained in:
parent
c6cbafbf61
commit
a7c60b23e0
2 changed files with 13 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
@ -14,6 +15,7 @@ using Discord;
|
|||
using Discord.Net;
|
||||
using Nito.AsyncEx;
|
||||
using ConnectionState = Discord.ConnectionState;
|
||||
using Message = Discord.Message;
|
||||
|
||||
namespace Discord_Media_Loader
|
||||
{
|
||||
|
@ -176,11 +178,18 @@ namespace Discord_Media_Loader
|
|||
|
||||
foreach (var a in m.Attachments)
|
||||
{
|
||||
while (clients.Count > 50)
|
||||
{
|
||||
// wait
|
||||
}
|
||||
var wc = new WebClient();
|
||||
clients.Add(wc);
|
||||
|
||||
wc.DownloadFileCompleted += (wcSender, wcE) => clients.Remove((WebClient)wcSender);
|
||||
wc.DownloadFile(new Uri(a.Url), $@"{path}\{a.Filename}");
|
||||
wc.DownloadFileCompleted += (wcSender, wcE) =>
|
||||
{
|
||||
clients.Remove(wc);
|
||||
};
|
||||
wc.DownloadFileAsync(new Uri(a.Url), $@"{path}\{a.Filename}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.1.0.28")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.28")]
|
||||
[assembly: AssemblyVersion("0.1.0.31")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.31")]
|
||||
|
|
Loading…
Add table
Reference in a new issue