From d6e2f0e811c1a321b67fdddc4ca644b306e75f89 Mon Sep 17 00:00:00 2001 From: soukoku Date: Sat, 19 Apr 2014 21:20:50 -0400 Subject: [PATCH] More sanity checks. --- NTwain/Data/TypesExtended.cs | 6 +++--- Tests/Tester.Console/Program.cs | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NTwain/Data/TypesExtended.cs b/NTwain/Data/TypesExtended.cs index f01554a..5486cc1 100644 --- a/NTwain/Data/TypesExtended.cs +++ b/NTwain/Data/TypesExtended.cs @@ -1700,14 +1700,14 @@ namespace NTwain.Data { return new TWIdentity { - Manufacturer = manufacturer ?? "UNKNOWN", + Manufacturer = string.IsNullOrEmpty(manufacturer) ? "UNKNOWN" : manufacturer, ProtocolMajor = TwainConst.ProtocolMajor, ProtocolMinor = TwainConst.ProtocolMinor, DataGroup = DataGroups.Control | supportedGroups, DataFunctionalities = DataFunctionalities.App2, - ProductFamily = productFamily ?? "UNKNOWN", - ProductName = productName ?? "UNKNOWN", + ProductFamily = string.IsNullOrEmpty(productFamily) ? "UNKNOWN" : productFamily, + ProductName = string.IsNullOrEmpty(productName) ? "UNKNOWN" : productName, Version = new TWVersion { Major = (short)version.Major, diff --git a/Tests/Tester.Console/Program.cs b/Tests/Tester.Console/Program.cs index c47f481..9eb9237 100644 --- a/Tests/Tester.Console/Program.cs +++ b/Tests/Tester.Console/Program.cs @@ -18,7 +18,10 @@ namespace Tester static void Main(string[] args) { // just an amusing example to do twain in console without UI - DoTwainWork(); + ThreadPool.QueueUserWorkItem(o => + { + DoTwainWork(); + }); Console.WriteLine("Test started, press Enter to exit."); Console.ReadLine(); } @@ -66,6 +69,10 @@ namespace Tester } } } + else + { + Console.WriteLine("Failed to open dsm with rc={0}!", rc); + } } static void twain_SourceDisabled(object sender, EventArgs e)