From b432ff3126a9d4549e084e3c074aefc92dc4ae6c Mon Sep 17 00:00:00 2001 From: Eugene Date: Thu, 31 Aug 2017 08:50:36 -0400 Subject: [PATCH] Make scanjet special casing. --- src/NTwain/TwainSessionInternal.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/NTwain/TwainSessionInternal.cs b/src/NTwain/TwainSessionInternal.cs index 1715707..2d80645 100644 --- a/src/NTwain/TwainSessionInternal.cs +++ b/src/NTwain/TwainSessionInternal.cs @@ -277,11 +277,21 @@ namespace NTwain // In any event the trick to get this thing working is to return from the callback first // before trying to process the msg or there will be unpredictable errors. - // changed to sync invoke instead of begininvoke for hp scanjet, not sure if will break other scanners :( - _msgLoopHook?.Invoke(() => + // changed to sync invoke instead of begininvoke for hp scanjet. + if (origin.ProductName.IndexOf("scanjet", StringComparison.OrdinalIgnoreCase) > -1) { - HandleSourceMsg(msg); - }); + _msgLoopHook?.Invoke(() => + { + HandleSourceMsg(msg); + }); + } + else + { + _msgLoopHook?.BeginInvoke(() => + { + HandleSourceMsg(msg); + }); + } return ReturnCode.Success; } return ReturnCode.Failure;