private void iconDownloadWorker_DoWork(object sender, DoWorkEventArgs e)
{
// Download and load icon in background
var uri = (Uri)e.Argument;
try
{
Debug.Assert(_iconCache != null);
string path = _iconCache.GetIcon(uri, _handler);
using (var stream = File.OpenRead(path))
e.Result = Image.FromStream(stream);
}
#region Error handling
catch (OperationCanceledException)
{}
catch (WebException ex)
{
Log.Warn(ex);
}
catch (IOException ex)
{
Log.Warn($"Failed to store icon from {uri}");
Log.Warn(ex);
}
catch (UnauthorizedAccessException ex)
{
Log.Warn($"Failed to store icon from {uri}");
Log.Warn(ex);
}
catch (ArgumentException ex)
{
Log.Warn($"Failed to parse icon from {uri}");
Log.Warn(ex);
}
#endregion
}