VintaSoft Twain .NET SDK v10.2
StopFeeder Method (Device)
Example 




Vintasoft.WpfTwain Namespace > Device Class : StopFeeder Method
Stops the automatic document feeder is possible.
Syntax
'Declaration
 
Public Sub StopFeeder() 
'Usage
 
Dim instance As Device
 
instance.StopFeeder()
public void StopFeeder()
public: void StopFeeder(); 
public:
void StopFeeder(); 
Exceptions
ExceptionDescription
Thrown if device not in the DeviceState.TransferReady state.
Thrown if feeder was not stopped.
Thrown if the .NET debugger is used and the function evaluation requires all threads to run.
Remarks
Call this method only when the ImageAcquired event is fired.
Example
This example show how to pause the image acquisition from feeder (stop the feeder) and resume the image acquisition from feeder.
Imports Vintasoft.Twain
            
Class SyncScan_StopFeeder
            
    ' This method scans the first image, stops the document feeder,
    ' scans the second image.
    Public Shared Sub ScanImage_StopFeeder_ScanImage()
        Dim imageCount As Integer = 0
            
        ' create the device manager
        Using deviceManager As New DeviceManager()
            deviceManager.IsTwain2Compatible = True
            ' open the device manager
            deviceManager.Open()
            
            ' get the device
            Dim deviceName As String = "KODAK Scanner: i5000"
            Dim device As Device = deviceManager.Devices.Find(deviceName)
            If device Is Nothing Then
                Throw New ApplicationException(String.Format("Device '{0}' is not found.", deviceName))
            End If
            
            ' disable device UI
            device.ShowUI = False
            ' specify that device must be closed after scan
            device.DisableAfterAcquire = True
            
            ' open the device
            device.Open()
            ' specify that 2 images must be acquired from scanner
            device.XferCount = 2
            
            ' run synchronous image acquisition
            Dim acquireModalState1 As AcquireModalState = AcquireModalState.None
            Do
                acquireModalState1 = device.AcquireModal()
                Select Case acquireModalState1
                    Case AcquireModalState.ImageAcquired
                        Console.WriteLine("Image is acquired.")
                        If device.AcquiredImage IsNot Nothing Then
                            device.AcquiredImage.Dispose()
                        End If
            
                        imageCount += 1
            
                        ' stop the feeder
                        device.StopFeeder()
                        Exit Select
            
                    Case AcquireModalState.ScanCompleted
                        Console.WriteLine("Scan is completed.")
                        Exit Select
            
                    Case AcquireModalState.ScanCanceled
                        Console.WriteLine("Scan is canceled.")
                        Exit Select
            
                    Case AcquireModalState.ScanFailed
                        Console.WriteLine(String.Format("Scan is failed: {0}.", device.ErrorString))
                        Exit Select
                End Select
            Loop While acquireModalState1 <> AcquireModalState.None
            
            If imageCount <> 1 Then
                Throw New ApplicationException("Wrong acquired image count.")
            End If
            
            If device.State <> DeviceState.TransferReady Then
                Throw New ApplicationException("Feeder is NOT stopped.")
            End If
            Console.WriteLine("Feeder is stopped.")
            
            ' continue asynchronous image acquisition
            Do
                acquireModalState1 = device.AcquireModal()
                Select Case acquireModalState1
                    Case AcquireModalState.ImageAcquired
                        Console.WriteLine("Image is acquired.")
            
                        If device.AcquiredImage IsNot Nothing Then
                            device.AcquiredImage.Dispose()
                        End If
            
                        imageCount = imageCount + 1
                        Exit Select
            
                    Case AcquireModalState.ScanCompleted
                        Console.WriteLine("Scan is completed.")
                        Exit Select
            
                    Case AcquireModalState.ScanCanceled
                        Console.WriteLine("Scan is canceled.")
                        Exit Select
            
                    Case AcquireModalState.ScanFailed
                        Console.WriteLine(String.Format("Scan is failed: {0}.", device.ErrorString))
                        Exit Select
                End Select
            Loop While acquireModalState1 <> AcquireModalState.None
            
            If imageCount <> 2 Then
                Throw New ApplicationException("Wrong acquired image count.")
            End If
            
            ' close the device
            device.Close()
        End Using
    End Sub
            
End Class
using System;
using Vintasoft.Twain;
            
namespace TwainExamples_CSharp
{
    class SyncScan_StopFeeder
    {
            
        // This method scans the first image, stops the document feeder,
        // scans the second image.
        public static void ScanImage_StopFeeder_ScanImage()
        {
            int imageCount = 0;
            
            // create the device manager
            using (DeviceManager deviceManager = new DeviceManager())
            {
                deviceManager.IsTwain2Compatible = true;
                // open the device manager
                deviceManager.Open();
            
                // get the device
                string deviceName = "KODAK Scanner: i5000";
                Device device = deviceManager.Devices.Find(deviceName);
                if (device == null)
                    throw new ApplicationException(string.Format("Device '{0}' is not found.", deviceName));
            
                // disable device UI
                device.ShowUI = false;
                // specify that device must be closed after scan
                device.DisableAfterAcquire = true;
            
                // open the device
                device.Open();
                // specify that 2 images must be acquired from scanner
                device.XferCount = 2;
            
                // run asynchronous image acquisition
                AcquireModalState acquireModalState = AcquireModalState.None;
                do
                {
                    acquireModalState = device.AcquireModal();
                    switch (acquireModalState)
                    {
                        case AcquireModalState.ImageAcquired:
                            Console.WriteLine("Image is acquired.");
                            if (device.AcquiredImage != null)
                                device.AcquiredImage.Dispose();
            
                            imageCount++;
            
                            // stop the feeder
                            device.StopFeeder();
                            break;
            
                        case AcquireModalState.ScanCompleted:
                            Console.WriteLine("Scan is completed.");
                            break;
            
                        case AcquireModalState.ScanCanceled:
                            Console.WriteLine("Scan is canceled.");
                            break;
            
                        case AcquireModalState.ScanFailed:
                            Console.WriteLine(string.Format("Scan is failed: {0}.", device.ErrorString));
                            break;
                    }
                }
                while (acquireModalState != AcquireModalState.None);
            
                if (imageCount != 1)
                    throw new ApplicationException("Wrong acquired image count.");
            
                if (device.State != DeviceState.TransferReady)
                    throw new ApplicationException("Feeder is NOT stopped.");
                Console.WriteLine("Feeder is stopped.");
            
                // continue asynchronous image acquisition
                do
                {
                    acquireModalState = device.AcquireModal();
                    switch (acquireModalState)
                    {
                        case AcquireModalState.ImageAcquired:
                            Console.WriteLine("Image is acquired.");
            
                            if (device.AcquiredImage != null)
                                device.AcquiredImage.Dispose();
            
                            imageCount++;
                            break;
            
                        case AcquireModalState.ScanCompleted:
                            Console.WriteLine("Scan is completed.");
                            break;
            
                        case AcquireModalState.ScanCanceled:
                            Console.WriteLine("Scan is canceled.");
                            break;
            
                        case AcquireModalState.ScanFailed:
                            Console.WriteLine(string.Format("Scan is failed: {0}.", device.ErrorString));
                            break;
                    }
                }
                while (acquireModalState != AcquireModalState.None);
            
                if (imageCount != 2)
                    throw new ApplicationException("Wrong acquired image count.");
            
                // close the device
                device.Close();
            }
        }
            
    }
}
Requirements

Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

See Also

Reference

Device Class
Device Members