PeterTh / gedosato

The Generic DownSampling Tool
GNU General Public License v3.0
462 stars 166 forks source link

Async Exceptions in Updater #407

Open bruce965 opened 6 years ago

bruce965 commented 6 years ago

Asynchronous methods do not throw exceptions, you should await for a result instead.

private void MainForm_Load(object sender, EventArgs e)
{
    // ...

    try
    {
        webClient.DownloadFileAsync(new Uri("https://github.com/PeterTh/gedosato/archive/master.zip"), "update.zip");
    }
    catch (Exception ex)
    {
        // ..
    }
}

Should be changed to:

private async Task MainForm_Load(object sender, EventArgs e)
{
    // ...

    try
    {
        await webClient.DownloadFileAsync(new Uri("https://github.com/PeterTh/gedosato/archive/master.zip"), "update.zip");
    }
    catch (Exception ex)
    {
        // ..
    }
}