Repository: dotnet/maui
File: src/Graphics/src/Graphics/Platforms/Windows/PlatformImage.cs (C#)

Code before:
				var targetWidth = factor * Width;
				var targetHeight = factor * Height;
				return ResizeInternal(targetWidth, targetHeight, 0, 0, targetWidth, targetHeight, disposeOriginal);
			}

			return this;
		}

		public IImage Downsize(float maxWidth, float maxHeight, bool disposeOriginal = false)
		{
			return ResizeInternal(maxWidth, maxHeight, 0, 0, maxWidth, maxHeight, disposeOriginal);
		}

		
		IImage ResizeInternal(float canvasWidth, float canvasHeight, float drawX, float drawY, float drawWidth, float drawHeight, bool disposeOriginal)
		{ 
			using var renderTarget = new CanvasRenderTarget(_creator, canvasWidth, canvasHeight, _bitmap.Dpi);

			using (var drawingSession = renderTarget.CreateDrawingSession())
			{
				drawingSession.DrawImage(_bitmap, new global::Windows.Foundation.Rect(drawX, drawY, drawWidth, drawHeight));
			}

			using (var resizedStream = new InMemoryRandomAccessStream())
			{
				renderTarget.SaveAsync(resizedStream, CanvasBitmapFileFormat.Png)
					.AsTask()
					.GetAwaiter()
					.GetResult();
				resizedStream.Seek(0);

				var newImage = FromStream(resizedStream.AsStreamForRead());

				if (disposeOriginal)
				{
					_bitmap.Dispose();
				}

				return newImage;
			}
		}

		public IImage Resize(float width, float height, ResizeMode resizeMode = ResizeMode.Fit,
			bool disposeOriginal = false)
		{
			// Calculate scaling factors
			float scaleX = width / Width;
			float scaleY = height / Height;

			float targetWidth = Width;
			float targetHeight = Height;

Review comment (refactor):
I understand why you use `GetAwaiter().GetResult()` here but, could avoid it? I think you can refactor the code to use a `ManualResetEventSlim` that will signal when the operation completes. Requires to set up a completion callback on the async operation and waits for the signal that the operation is complete.

```
var saveCompletedEvent = new ManualResetEventSlim(false);

saveCompletedEvent.Wait();
```

Code after:
				var targetWidth = factor * Width;
				var targetHeight = factor * Height;
				return ResizeInternal(targetWidth, targetHeight, 0, 0, targetWidth, targetHeight, disposeOriginal);
			}

			return this;
		}

		public IImage Downsize(float maxWidth, float maxHeight, bool disposeOriginal = false)
		{
			return ResizeInternal(maxWidth, maxHeight, 0, 0, maxWidth, maxHeight, disposeOriginal);
		}

		
		IImage ResizeInternal(float canvasWidth, float canvasHeight, float drawX, float drawY, float drawWidth, float drawHeight, bool disposeOriginal)
		{ 
			using var renderTarget = new CanvasRenderTarget(_creator, canvasWidth, canvasHeight, _bitmap.Dpi);

			using (var drawingSession = renderTarget.CreateDrawingSession())
			{
				drawingSession.DrawImage(_bitmap, new global::Windows.Foundation.Rect(drawX, drawY, drawWidth, drawHeight));
			}

			using (var resizedStream = new InMemoryRandomAccessStream())
			{
				var saveCompletedEvent = new ManualResetEventSlim(false);
				Exception saveException = null;

				// Start the async save operation
				var saveTask = renderTarget.SaveAsync(resizedStream, CanvasBitmapFileFormat.Png).AsTask();

				saveTask.ContinueWith(task =>
				{
					if (task.Exception is not null)
					{
						saveException = task.Exception;
					}
					// Signal that the operation is complete
					saveCompletedEvent.Set();
				});

				// Wait for the signal
				saveCompletedEvent.Wait();

				// Check for any exceptions during the async operation
				if (saveException is not null)
				{
					throw saveException;
				}
				
				resizedStream.Seek(0);