mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-09 11:21:06 +08:00
Replaced preproc guards that no longer work.
This commit is contained in:
16
src/NTwain/OperatingSystem.cs
Normal file
16
src/NTwain/OperatingSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
|
||||
namespace NTwain;
|
||||
|
||||
/// <summary>
|
||||
/// Hack to make it build without preprocessor directives all over.
|
||||
/// </summary>
|
||||
static class OperatingSystem
|
||||
{
|
||||
public static bool IsWindows()
|
||||
{
|
||||
return Environment.OSVersion.Platform == PlatformID.Win32NT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -30,9 +30,10 @@ namespace NTwain
|
||||
{
|
||||
if (logger != null) _logger = logger;
|
||||
|
||||
#if WINDOWS || NETFRAMEWORK
|
||||
DSM.DsmLoader.TryLoadCustomDSM(Logger);
|
||||
#endif
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
DSM.DsmLoader.TryLoadCustomDSM(Logger);
|
||||
|
||||
_appIdentity = appId;
|
||||
|
||||
_legacyCallbackDelegate = LegacyCallbackHandler;
|
||||
@@ -69,9 +70,8 @@ namespace NTwain
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
#if WINDOWS || NETFRAMEWORK
|
||||
t.SetApartmentState(ApartmentState.STA); // just in case
|
||||
#endif
|
||||
if (OperatingSystem.IsWindows())
|
||||
t.SetApartmentState(ApartmentState.STA); // just in case
|
||||
t.Start();
|
||||
}
|
||||
|
||||
@@ -102,9 +102,10 @@ namespace NTwain
|
||||
_xferReady.Dispose();
|
||||
//_bgPendingMsgs.CompleteAdding();
|
||||
}
|
||||
#if WINDOWS || NETFRAMEWORK
|
||||
if (_procEvent.pEvent != IntPtr.Zero) Marshal.FreeHGlobal(_procEvent.pEvent);
|
||||
#endif
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
if (_procEvent.pEvent != IntPtr.Zero) Marshal.FreeHGlobal(_procEvent.pEvent);
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user