Code: Select all
; Make the call
lResult=DeviceIoControl_(*SCSI\hDevice, ; handle to the SPTI device
#IOCTL_SCSI_PASS_THROUGH_DIRECT, ; [in] dwControlCode
*SCSI\SPTDWS\SPTD, ; [in] pointer to the SPTD structure
SizeOf(SCSI_PASS_THROUGH_DIRECT), ; [in] the size of the SPTD structure
*SCSI\SPTDWS\SPTD, ; [out] pointer to the output SPTDWS structure (overwrites input SPTD)
SizeOf(SCSI_PASS_THROUGH_DIRECT_WITH_SENSE),; the size of the SPTDWS structure (to include Sense buffer at specified offset)
@lBytesRet, ; [out] pointer to a variable that received the size of data returned
#Null) ; [N/A] not used for non-overlapped operations
I'm working with relatively slow SCSI tape drives and some SCSI operations (like load / unload medium and rewind) can take 30s or more to complete, during which the main GUI often goes into the 'not responding' state, until the command completes, which I want to avoid.
I've tested having a sub thread to handle the SCSI operations but this makes no difference - the main and GUI sub threads in my application still pause until the DeviceIoControl() call made by the SCSI sub thread, returns.
Is this expected behaviour in Windows 10/11? Is there a better way to code this, other than modifying the SCSI CDB for IMMED=1 or using overlapped mode to reduce the time spent in DeviceIoControl() ? Thanks.