Skip to content

Commit

Permalink
Apple: Fix chaining callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Dec 23, 2024
1 parent 59ab856 commit ed60579
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion NAPS2.Sdk/Scan/Internal/Apple/DeviceOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ public override void DidScanToBandData(ICScannerDevice scanner, ICScannerBandDat
_buffer = null;
var tcs = new TaskCompletionSource<IMemoryImage?>();
// Ensure sequencing is maintained when writing to the callback even if copy tasks finish out of order
_writeToCallback = (_writeToCallback ?? Task.CompletedTask).ContinueWith(async _ =>
var previousCallback = _writeToCallback ?? Task.CompletedTask;
_writeToCallback = Task.Run(async () =>
{
await previousCallback;
var image = await tcs.Task;
if (image != null)
{
Expand Down

0 comments on commit ed60579

Please sign in to comment.