Remove Task.Run in ImageLoader.LoadImageAsync

This commit is contained in:
ClemensFischer 2025-02-23 18:38:34 +01:00
parent edcdeb09c1
commit f03a627a86
3 changed files with 10 additions and 16 deletions

View file

@ -32,12 +32,10 @@ namespace MapControl
return Task.FromResult<IImage>(null);
}
return Task.Run(() =>
using (var stream = File.OpenRead(path))
{
using var stream = File.OpenRead(path);
return LoadImage(stream);
});
return LoadImageAsync(stream);
}
}
internal static async Task<IImage> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)

View file

@ -132,12 +132,11 @@ namespace MapControl
var file = Path.GetFileNameWithoutExtension(sourcePath);
var worldFilePath = Path.Combine(dir, file + ext.Remove(2, 1) + "w");
if (File.Exists(worldFilePath))
if (await ImageLoader.LoadImageAsync(sourcePath) is BitmapSource bitmap)
{
return new GeoBitmap(
(BitmapSource)await ImageLoader.LoadImageAsync(sourcePath),
await ReadWorldFileMatrix(worldFilePath),
null);
var transform = await ReadWorldFileMatrix(worldFilePath);
return new GeoBitmap(bitmap, transform, null);
}
}

View file

@ -43,13 +43,10 @@ namespace MapControl
return Task.FromResult<ImageSource>(null);
}
return Task.Run(() =>
using (var stream = File.OpenRead(path))
{
using (var stream = File.OpenRead(path))
{
return LoadImage(stream);
}
});
return LoadImageAsync(stream);
}
}
internal static async Task<ImageSource> LoadMergedImageAsync(Uri uri1, Uri uri2, IProgress<double> progress)