Klausur-Deckblatt: Fortschrittsbalken und Erzeugung im Hintergrund
CI / build-and-test (push) Canceled after 0s
CI / build-and-test (push) Canceled after 0s
Ein Klassensatz dauert spürbar und fror den Dialog ein. GenerateAsync setzt jetzt per Task.Run, RenderBatchToPdf meldet jeden gesetzten Datensatz über ein optionales IProgress<int>. Das abschließende Document.Merge meldet nichts, dort läuft der Balken unbestimmt. Währenddessen sind die Schaltflächen gesperrt und der Dialog bleibt offen. Ein einzelnes Deckblatt wird nicht mehr doppelt gesetzt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
24a30881f3
commit
e4a81e8974
9 files changed
+93
-23
No files matched your search
@@ -61,14 +61,17 @@ public sealed class ExamCoverTemplatingTests : IDisposable
|
||||
var tall = new DrawingValue(
|
||||
[new DrawStringEx(0, 290, 12, 170, "LANG", DrawingTextAlignment.AlignLeft, 10)], 300);
|
||||
|
||||
var progress = new RecordingProgress();
|
||||
|
||||
var result = new QuestTemplateRenderer().RenderBatchToPdf(template,
|
||||
[
|
||||
new DictionaryProvider(new Dictionary<string, PlaceholderValue> { ["Tabelle"] = ShortDrawing }),
|
||||
new DictionaryProvider(new Dictionary<string, PlaceholderValue> { ["Tabelle"] = tall }),
|
||||
]);
|
||||
], progress);
|
||||
|
||||
using var document = UglyToad.PdfPig.PdfDocument.Open(result.Pdf);
|
||||
Assert.Equal([1, 2], result.PageCounts);
|
||||
Assert.Equal([1, 2], progress.Reported);
|
||||
Assert.Equal(3, document.NumberOfPages);
|
||||
Assert.Contains("TABELLE", document.GetPage(1).Text);
|
||||
}
|
||||
|
||||
@@ -394,3 +394,11 @@ internal sealed class DictionaryProvider(IReadOnlyDictionary<string, Placeholder
|
||||
{
|
||||
public IReadOnlyDictionary<string, PlaceholderValue> GetValues() => values;
|
||||
}
|
||||
|
||||
/// <summary>Zeichnet Meldungen synchron auf — <see cref="Progress{T}"/> würde sie ohne
|
||||
/// SynchronizationContext erst später auf dem Threadpool zustellen.</summary>
|
||||
internal sealed class RecordingProgress : IProgress<int>
|
||||
{
|
||||
public List<int> Reported { get; } = [];
|
||||
public void Report(int value) => Reported.Add(value);
|
||||
}
|
||||
Reference in new issue
Block a user