// final method that handles msg from the source, whether it's from wndproc or callbacks void HandleSourceMsg(Message msg) { PlatformInfo.Current.Log.Debug("Got TWAIN msg " + msg); switch (msg) { case Message.XferReady: if (State < 6) { State = 6; } TransferLogic.DoTransferRoutine(this); break; case Message.DeviceEvent: TWDeviceEvent de; var rc = ((ITwainSessionInternal)this).DGControl.DeviceEvent.Get(out de); if (rc == ReturnCode.Success) { SafeSyncableRaiseOnEvent(OnDeviceEvent, DeviceEvent, new DeviceEventArgs(de)); } break; case Message.CloseDSReq: case Message.CloseDSOK: DisableReason = msg; // even though it says closeDS it's really disable. // dsok is sent if source is enabled with uionly // some sources send this at other states so do a step down if (State > 5) { // rather than do a close here let the transfer logic handle the close down now //ForceStepDown(4); _closeRequested = true; } else if (State == 5) { // needs this state check since some source sends this more than once ((ITwainSessionInternal)this).DisableSource(); } break; } }