PeterTh/gedosato

Async Exceptions in Updater

bruce965 opened this issue · 0 comments

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)
	{
		// ..
	}
}