solve 'edge' case and pass cancellation token

This commit is contained in:
Dennis Arfan 2025-08-01 22:13:13 +07:00
parent 0472bfe58e
commit d3dfdd6a74
15 changed files with 208 additions and 551 deletions

View file

@ -15,19 +15,23 @@ public static class Utils
dto.CropSize![0],
dto.CropSize![1]);
public static async Task WriteToStream(this GridSection section, Stream stream, float? scale)
public static async Task WriteToStream(
this GridSection section,
Stream stream,
float? scale,
CancellationToken cancellationToken = default)
{
var imageCreator = new ImageCreator(section);
await imageCreator.WriteToStream(stream, scale!.Value);
using var imageCreator = new DangerousImageCreator(section);
await imageCreator.WriteToStream(stream, scale!.Value, cancellationToken);
}
public static async Task DangerousWriteToPipe(
public static async Task WriteToPipe(
this GridSection section,
PipeWriter pipeWriter,
float? scale,
CancellationToken cancellationToken = default)
{
var imageCreator = new DangerousImageCreator(section);
using var imageCreator = new DangerousImageCreator(section);
await imageCreator.WriteToPipe(pipeWriter, scale!.Value, cancellationToken);
}
}