mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Added check for msg loop hook being null.
This commit is contained in:
@@ -280,7 +280,7 @@ namespace NTwain
|
|||||||
public ReturnCode Close()
|
public ReturnCode Close()
|
||||||
{
|
{
|
||||||
var rc = ReturnCode.Failure;
|
var rc = ReturnCode.Failure;
|
||||||
_msgLoopHook.Invoke(() =>
|
_msgLoopHook?.Invoke(() =>
|
||||||
{
|
{
|
||||||
PlatformInfo.Current.Log.Debug("Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId);
|
PlatformInfo.Current.Log.Debug("Thread {0}: CloseManager.", Thread.CurrentThread.ManagedThreadId);
|
||||||
|
|
||||||
@@ -289,6 +289,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
PlatformInfo.InternalCurrent.MemoryManager = null;
|
PlatformInfo.InternalCurrent.MemoryManager = null;
|
||||||
_msgLoopHook.Stop();
|
_msgLoopHook.Stop();
|
||||||
|
_msgLoopHook = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return rc;
|
return rc;
|
||||||
@@ -398,7 +399,7 @@ namespace NTwain
|
|||||||
// success, the return status from DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER may
|
// success, the return status from DG_CONTROL / DAT_PENDINGXFERS / MSG_ENDXFER may
|
||||||
// be ignored.
|
// be ignored.
|
||||||
|
|
||||||
_msgLoopHook.Invoke(() =>
|
_msgLoopHook?.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (targetState < 7 && CurrentSource != null)
|
if (targetState < 7 && CurrentSource != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ namespace NTwain
|
|||||||
DisableReason = Message.Null;
|
DisableReason = Message.Null;
|
||||||
var rc = ReturnCode.Failure;
|
var rc = ReturnCode.Failure;
|
||||||
|
|
||||||
_msgLoopHook.Invoke(() =>
|
_msgLoopHook?.Invoke(() =>
|
||||||
{
|
{
|
||||||
PlatformInfo.Current.Log.Debug("Thread {0}: EnableSource with {1}.", Thread.CurrentThread.ManagedThreadId, mode);
|
PlatformInfo.Current.Log.Debug("Thread {0}: EnableSource with {1}.", Thread.CurrentThread.ManagedThreadId, mode);
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ namespace NTwain
|
|||||||
_disabling = true;
|
_disabling = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_msgLoopHook.Invoke(() =>
|
_msgLoopHook?.Invoke(() =>
|
||||||
{
|
{
|
||||||
PlatformInfo.Current.Log.Debug("Thread {0}: DisableSource.", Thread.CurrentThread.ManagedThreadId);
|
PlatformInfo.Current.Log.Debug("Thread {0}: DisableSource.", Thread.CurrentThread.ManagedThreadId);
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ namespace NTwain
|
|||||||
|
|
||||||
// In any event the trick to get this thing working is to return from the callback first
|
// 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.
|
// before trying to process the msg or there will be unpredictable errors.
|
||||||
_msgLoopHook.BeginInvoke(() =>
|
_msgLoopHook?.BeginInvoke(() =>
|
||||||
{
|
{
|
||||||
HandleSourceMsg(msg);
|
HandleSourceMsg(msg);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user