VintaSoftTwain Control v6.0
VintaSoftTwain Object / DeviceAsyncEvent Event
Get the event that has taken place.
Gets the name of the device that generated the event.
Gets the minutes of battery power remaining.
Gets the percentage of battery power remaining.
Gets the current power supply in use.
Gets the current X resolution.
Gets the current Y resolution.
Gets the current flash setting.
Gets the number of images camera will capture.
Gets the hundredths of a second between captures.
In This Topic
    DeviceAsyncEvent Event
    In This Topic
    Description
    Occurs when the asynchronous device event is occurs.
    Syntax
    Visual Basic
    Public Event DeviceAsyncEvent( _
       ByVal deviceEvent As Long, _
       ByVal deviceName As String, _
       ByVal batteryMinutes As Double, _
       ByVal batteryPercentage As Integer, _
       ByVal powerSupply As Long, _
       ByVal resolutionX As Single, _
       ByVal resolutionY As Single, _
       ByVal flashUsed As Long, _
       ByVal automaticCapture As Double, _
       ByVal timeBeforeFirstCapture As Double, _
       ByVal timeBetweenCaptures As Double _
    )
    Parameters
    deviceEvent
    Get the event that has taken place.
    deviceName
    Gets the name of the device that generated the event.
    batteryMinutes
    Gets the minutes of battery power remaining.
    batteryPercentage
    Gets the percentage of battery power remaining.
    powerSupply
    Gets the current power supply in use.
    resolutionX
    Gets the current X resolution.
    resolutionY
    Gets the current Y resolution.
    flashUsed
    Gets the current flash setting.
    automaticCapture
    Gets the number of images camera will capture.
    timeBeforeFirstCapture
    timeBetweenCaptures
    Gets the hundredths of a second between captures.
    Example
    This example shows how to detect when paper is jammed.
    Private VSTwain1 As New VintaSoftTwain()
    
    
    ''' <summary>
    ''' Scans images asynchronously.
    ''' </summary>
    Private Sub ScanImages()
        VSTwain1.Device_Open()
        If VSTwain1.DeviceManager_ShowDefaultDeviceSelectionDialog() Then
            VSTwain1.Device_ShowUI = True
    
            Try
                ' get events supported by device
                Dim supportedDeviceEvents As Array = VSTwain1.Device_GetSupportedAsyncEvents()
                If (Not IsNothing(supportedDeviceEvents)) Then
                    ' for each supported event
                    For i As Integer = 0 To supportedDeviceEvents.Length - 1
                        ' if device can report when paper is jammed
                        If supportedDeviceEvents(i) = 13 Then
                            ' specify that device must report when paper is jammed
                            VSTwain1.Device_AsyncEvents = New Int32() {13}
    
                            ' subscribe to the device event
                            AddHandler VSTwain1.DeviceAsyncEvent, AddressOf VSTwain1_AsyncEvent
    
                            Exit For
                        End If
                    Next
                End If
            Catch ex As Exception
                Console.WriteLine(ex.ToString())
            End Try
    
            ' subscribe to the device events
            AddHandler VSTwain1.DeviceImageAcquired, AddressOf VSTwain1_ImageAcquired
            AddHandler VSTwain1.DeviceScanCompleted, AddressOf VSTwain1_ScanCompleted
            AddHandler VSTwain1.DeviceScanFailed, AddressOf VSTwain1_ScanFailed
            AddHandler VSTwain1.DeviceScanCanceled, AddressOf VSTwain1_ScanCanceled
    
            ' acquire images asynchronously
            VSTwain1.Device_AcquireImage()
        End If
    End Sub
    
    Private Sub VSTwain1_AsyncEvent(deviceEvent As Integer, _
                                    deviceName As String, _
                                    batteryMinutes As Double, _
                                    batteryPercentage As Short, _
                                    powerSupply As Integer, _
                                    resolutionX As Single, _
                                    resolutionY As Single, _
                                    flashUsed As Integer, _
                                    automaticCapture As Double, _
                                    timeBeforeFirstCapture As Double, _
                                    timeBetweenCaptures As Double)
        Console.WriteLine("Paper is jammed.")
    End Sub
    
    Private Sub VSTwain1_ImageAcquired()
        ' get index of acquired image
        Dim imageIndex As Integer = VSTwain1.AcquiredImages_Count - 1
    
        ' save acquired image to TIFF file
        If Not VSTwain1.AcquiredImages_Save(0, "c:\test.tiff") Then
            Console.WriteLine(VSTwain1.errorString)
        End If
    End Sub
    
    Private Sub VSTwain1_ScanCompleted()
        Console.WriteLine("Scan is completed.")
    End Sub
    
    Private Sub VSTwain1_ScanFailed(errorString As String)
        Console.WriteLine(String.Format("Scan is failed: {0}.", errorString))
    End Sub
    
    Private Sub VSTwain1_ScanCanceled()
        Console.WriteLine("Scan is canceled.")
    End Sub
    See Also