Fixed creating/opening/closing twainsession multiple times in an app not working.

This commit is contained in:
soukoku
2014-08-14 07:34:55 -04:00
parent a8891efe3b
commit f073bc6b65
13 changed files with 147 additions and 53 deletions

View File

@@ -54,12 +54,18 @@ namespace NTwain
internal static TwainSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId)
{
TwainSource source = null;
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
if (__ownedSources.ContainsKey(key))
{
return __ownedSources[key];
source = __ownedSources[key];
source.Session = session;
}
return __ownedSources[key] = new TwainSource(session, sourceId);
else
{
__ownedSources[key] = source = new TwainSource(session, sourceId);
}
return source;
}
/// <summary>