Optimized image downloading

This commit is contained in:
erri120 2019-10-09 15:44:25 +02:00
parent c1b5b1cef1
commit ebfd78e051
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135

View File

@ -460,12 +460,15 @@ namespace Wabbajack
private void CacheSlide(string url, string dest)
{
bool sync = false;
dispatcher.Invoke(() => {
var file = new FileStream(dest, FileMode.Create, FileAccess.Write);
using (var file = new FileStream(dest, FileMode.Create, FileAccess.Write))
{
if (sync)
{
using (var stream = new HttpClient().GetStreamSync(url))
stream.CopyTo(file);
dispatcher.Invoke(() =>
{
using (var stream = new HttpClient().GetStreamSync(url))
stream.CopyTo(file);
});
}
else
{
@ -473,9 +476,9 @@ namespace Wabbajack
{
stream.Wait();
stream.Result.CopyTo(file);
}
}
}
});
}
}
/// <summary>
/// Queues a random slide