Fixed problem with calls to TwainAppSession.CloseDSMAsync() never returning.

This commit is contained in:
Steffen S. Hellestøl
2025-07-05 17:15:24 +02:00
parent 83ab3d5f0a
commit 44e0c7ab07
2 changed files with 4 additions and 3 deletions

View File

@@ -69,12 +69,12 @@ namespace NTwain
/// <summary>
/// Detatches a previously attached session and stops the thread.
/// </summary>
public async Task<STS> DetatchAsync()
public async Task<STS> DetachAsync()
{
STS sts = default;
if (_dummyForm != null && _twain != null)
{
TaskCompletionSource<bool> tcs = new();
TaskCompletionSource<STS> tcs = new();
_dummyForm.BeginInvoke(() =>
{
sts = _twain.CloseDSMReal();
@@ -84,6 +84,7 @@ namespace NTwain
_dummyForm.Close();
_twain = null;
}
tcs.SetResult(sts);
});
await tcs.Task;
}

View File

@@ -144,7 +144,7 @@ namespace NTwain
{
if (_selfPump == null) throw new InvalidOperationException($"Cannot close if not opened with {nameof(OpenDSMAsync)}().");
var sts = await _selfPump.DetatchAsync();
var sts = await _selfPump.DetachAsync();
if (sts.IsSuccess)
{
_selfPump = null;