Use Async method name suffix consistently

This commit is contained in:
ClemensFischer 2023-08-19 17:48:52 +02:00
parent f3aad38814
commit adc34b6591
9 changed files with 29 additions and 28 deletions

View file

@ -86,13 +86,13 @@ namespace MapControl
if (File.Exists(worldFilePath))
{
geoBitmap = await ReadWorldFileImage(sourcePath, worldFilePath);
geoBitmap = await ReadWorldFileImageAsync(sourcePath, worldFilePath);
}
}
if (geoBitmap == null)
{
geoBitmap = await ReadGeoTiff(sourcePath);
geoBitmap = await ReadGeoTiffAsync(sourcePath);
}
image = new Image
@ -136,7 +136,7 @@ namespace MapControl
MapPanel.SetBoundingBox(this, boundingBox);
}
private static async Task<GeoBitmap> ReadWorldFileImage(string sourcePath, string worldFilePath)
private static async Task<GeoBitmap> ReadWorldFileImageAsync(string sourcePath, string worldFilePath)
{
var bitmap = (BitmapSource)await ImageLoader.LoadImageAsync(sourcePath);

View file

@ -56,8 +56,7 @@ namespace MapControl
}
public static readonly DependencyProperty SourcePathProperty = DependencyProperty.Register(
nameof(SourcePath), typeof(string), typeof(GroundOverlay),
new PropertyMetadata(null, async (o, e) => await ((GroundOverlay)o).SourcePathPropertyChanged((string)e.NewValue)));
nameof(SourcePath), typeof(string), typeof(GroundOverlay), new PropertyMetadata(null, SourcePathPropertyChanged));
public string SourcePath
{
@ -65,8 +64,10 @@ namespace MapControl
set => SetValue(SourcePathProperty, value);
}
private async Task SourcePathPropertyChanged(string sourcePath)
private static async void SourcePathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var groundOverlay = (GroundOverlay)obj;
var sourcePath = (string)e.NewValue;
IEnumerable<ImageOverlay> imageOverlays = null;
if (!string.IsNullOrEmpty(sourcePath))
@ -90,11 +91,11 @@ namespace MapControl
}
}
Children.Clear();
groundOverlay.Children.Clear();
if (imageOverlays != null)
{
AddImageOverlays(imageOverlays);
groundOverlay.AddImageOverlays(imageOverlays);
}
}

View file

@ -25,7 +25,7 @@ namespace MapControl
{
public interface ITileImageLoader
{
Task LoadTiles(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName, IProgress<double> progress);
Task LoadTilesAsync(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName, IProgress<double> progress);
}
public abstract class MapTileLayerBase : Panel, IMapLayer
@ -195,7 +195,7 @@ namespace MapControl
protected Task LoadTiles(IEnumerable<Tile> tiles, string cacheName)
{
return TileImageLoader.LoadTiles(tiles, TileSource, cacheName, loadingProgress);
return TileImageLoader.LoadTilesAsync(tiles, TileSource, cacheName, loadingProgress);
}
private Task Update(bool tileSourceChanged)

View file

@ -62,7 +62,7 @@ namespace MapControl
/// If tileSource.UriFormat starts with "http" and cacheName is a non-empty string,
/// tile images will be cached in the TileImageLoader's Cache - if that is not null.
/// </summary>
public Task LoadTiles(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName, IProgress<double> progress)
public Task LoadTilesAsync(IEnumerable<Tile> tiles, TileSource tileSource, string cacheName, IProgress<double> progress)
{
pendingTiles?.Clear();
@ -85,7 +85,7 @@ namespace MapControl
var tileQueue = pendingTiles; // pendingTiles may change while tasks are running
var tasks = new Task[taskCount];
async Task LoadTilesFromQueue()
async Task LoadTilesFromQueueAsync()
{
while (tileQueue.TryDequeue(out var tile))
{
@ -93,7 +93,7 @@ namespace MapControl
try
{
await LoadTile(tile, tileSource, cacheName).ConfigureAwait(false);
await LoadTileAsync(tile, tileSource, cacheName).ConfigureAwait(false);
}
catch (Exception ex)
{
@ -104,7 +104,7 @@ namespace MapControl
for (int i = 0; i < taskCount; i++)
{
tasks[i] = Task.Run(LoadTilesFromQueue);
tasks[i] = Task.Run(LoadTilesFromQueueAsync);
}
return Task.WhenAll(tasks);
@ -114,11 +114,11 @@ namespace MapControl
return Task.CompletedTask;
}
private static Task LoadTile(Tile tile, TileSource tileSource, string cacheName)
private static Task LoadTileAsync(Tile tile, TileSource tileSource, string cacheName)
{
if (string.IsNullOrEmpty(cacheName))
{
return LoadTile(tile, () => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel));
return LoadTileAsync(tile, () => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel));
}
var uri = tileSource.GetUri(tile.Column, tile.Row, tile.ZoomLevel);
@ -135,7 +135,7 @@ namespace MapControl
var cacheKey = string.Format(CultureInfo.InvariantCulture,
"{0}/{1}/{2}/{3}{4}", cacheName, tile.ZoomLevel, tile.Column, tile.Row, extension);
return LoadCachedTile(tile, uri, cacheKey);
return LoadCachedTileAsync(tile, uri, cacheKey);
}
return Task.CompletedTask;

View file

@ -33,7 +33,7 @@ namespace MapControl
public static Caching.IImageCache Cache { get; set; }
private static async Task LoadCachedTile(Tile tile, Uri uri, string cacheKey)
private static async Task LoadCachedTileAsync(Tile tile, Uri uri, string cacheKey)
{
var cacheItem = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
var buffer = cacheItem?.Item1;
@ -53,11 +53,11 @@ namespace MapControl
if (buffer != null && buffer.Length > 0)
{
await LoadTile(tile, () => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
await LoadTileAsync(tile, () => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
}
}
private static async Task LoadTile(Tile tile, Func<Task<ImageSource>> loadImageFunc)
private static async Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
{
var tcs = new TaskCompletionSource<object>();

View file

@ -13,7 +13,7 @@ namespace MapControl
{
public partial class GeoImage
{
private static async Task<GeoBitmap> ReadGeoTiff(string sourcePath)
private static async Task<GeoBitmap> ReadGeoTiffAsync(string sourcePath)
{
return await Task.Run(() =>
{

View file

@ -24,7 +24,7 @@ namespace MapControl
public static ObjectCache Cache { get; set; } = MemoryCache.Default;
private static async Task LoadCachedTile(Tile tile, Uri uri, string cacheKey)
private static async Task LoadCachedTileAsync(Tile tile, Uri uri, string cacheKey)
{
var cacheItem = Cache.Get(cacheKey) as Tuple<byte[], DateTime>;
var buffer = cacheItem?.Item1;
@ -46,11 +46,11 @@ namespace MapControl
if (buffer != null && buffer.Length > 0)
{
await LoadTile(tile, () => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
await LoadTileAsync(tile, () => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
}
}
private static async Task LoadTile(Tile tile, Func<Task<ImageSource>> loadImageFunc)
private static async Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
{
var image = await loadImageFunc().ConfigureAwait(false);

View file

@ -11,7 +11,7 @@ namespace MapControl
{
public partial class GeoImage
{
private static async Task<GeoBitmap> ReadGeoTiff(string sourcePath)
private static async Task<GeoBitmap> ReadGeoTiffAsync(string sourcePath)
{
var file = await StorageFile.GetFileFromPathAsync(FilePath.GetFullPath(sourcePath));

View file

@ -34,7 +34,7 @@ namespace MapControl
public static Caching.IImageCache Cache { get; set; }
private static async Task LoadCachedTile(Tile tile, Uri uri, string cacheKey)
private static async Task LoadCachedTileAsync(Tile tile, Uri uri, string cacheKey)
{
var cacheItem = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
var buffer = cacheItem?.Item1;
@ -54,11 +54,11 @@ namespace MapControl
if (buffer != null && buffer.Length > 0)
{
await LoadTile(tile, () => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
await LoadTileAsync(tile, () => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
}
}
private static Task LoadTile(Tile tile, Func<Task<ImageSource>> loadImageFunc)
private static Task LoadTileAsync(Tile tile, Func<Task<ImageSource>> loadImageFunc)
{
var tcs = new TaskCompletionSource();