VintaSoft Twain .NET SDK v10.2
JobControl Property (Device)
Example 




Vintasoft.Twain Namespace > Device Class : JobControl Property
Allows multiple jobs in batch mode.
Syntax
'Declaration
 
Public Property JobControl As JobControl
'Usage
 
Dim instance As Device
Dim value As JobControl
 
instance.JobControl = value
 
value = instance.JobControl
public JobControl JobControl {get; set;}
public: __property JobControl get_JobControl();
public: __property void set_JobControl( 
   JobControl value
);
public:
property JobControl JobControl {
   JobControl get();
   void set (    JobControl value);
}
Exceptions
ExceptionDescription
Thrown if device is in wrong state.
Thrown if device does not support capability.
Thrown if the .NET debugger is used and the function evaluation requires all threads to run.
Remarks
Call this property only when device is opened (State == DeviceState.Opened).

Supported values of brightness can be received by the GetSupportedJobControlValues method.
Example
This example shows how to detect job separators during scanning.
Private _deviceManager As DeviceManager
Private _device As Device
Private _jobCounter As Integer = -1
            
Public Sub ScanImageWithJobControl()
    Try
        ' create and open device manager
        _deviceManager = New DeviceManager()
        _deviceManager.Open()
            
        ' get reference to the default device
        _device = _deviceManager.DefaultDevice
        ' subscribe to device events
        AddHandler _device.ImageAcquired, New EventHandler(Of ImageAcquiredEventArgs)(AddressOf _device1_ImageAcquired)
        AddHandler _device.ScanCompleted, New EventHandler(AddressOf _device1_ScanCompleted)
        AddHandler _device.ScanCanceled, New EventHandler(AddressOf _device1_ScanCanceled)
        AddHandler _device.ScanFailed, New EventHandler(Of ScanFailedEventArgs)(AddressOf _device1_ScanFailed)
        AddHandler _device.ScanFinished, New EventHandler(AddressOf _device1_ScanFinished)
            
        _device.ShowUI = False
        _device.DisableAfterAcquire = True
            
        ' open the device
        _device.Open()
            
        ' set scanning settings
        _device.JobControl = JobControl.DetectAndIncludeJobSeparatorAndContinueScanning
        _jobCounter = _jobCounter + 1
            
        ' acquire images from device
        _device.Acquire()
    Catch ex As TwainException
        Console.WriteLine(ex.Message)
    End Try
End Sub
            
Private Sub _device1_ImageAcquired(ByVal sender As Object, ByVal e As ImageAcquiredEventArgs)
    If _device.EndOfJob Then
        _jobCounter = _jobCounter + 1
    Else
        Try
            ' save the acquired image
            e.Image.Save(String.Format("c:\job{0}.tif", _jobCounter))
            
            ' dispose the acquired image
            e.Image.Dispose()
        Catch ex As ImagingException
            Console.WriteLine(ex.Message)
        End Try
    End If
End Sub
            
Private Sub _device1_ScanCompleted(ByVal sender As Object, ByVal e As EventArgs)
    Console.WriteLine("Scan is completed.")
End Sub
            
Private Sub _device1_ScanCanceled(ByVal sender As Object, ByVal e As EventArgs)
    Console.WriteLine("Scan is canceled.")
End Sub
            
Private Sub _device1_ScanFailed(ByVal sender As Object, ByVal e As ScanFailedEventArgs)
    Console.WriteLine(String.Format("Scan is failed: {0}", e.ErrorString))
End Sub
            
Private Sub _device1_ScanFinished(ByVal sender As Object, ByVal e As EventArgs)
    ' close the device
    _device.Close()
End Sub
DeviceManager _deviceManager;
Device _device;
int _jobCounter = -1;
            
public void ScanImageWithJobControl()
{
    try
    {
        // create and open device manager
        _deviceManager = new DeviceManager();
        _deviceManager.Open();
            
        // get reference to the default device
        _device = _deviceManager.DefaultDevice;
        // subscribe to device events
        _device.ImageAcquired += new EventHandler<ImageAcquiredEventArgs>(_device1_ImageAcquired);
        _device.ScanCompleted += new EventHandler(_device1_ScanCompleted);
        _device.ScanCanceled += new EventHandler(_device1_ScanCanceled);
        _device.ScanFailed += new EventHandler<ScanFailedEventArgs>(_device1_ScanFailed);
        _device.ScanFinished += new EventHandler(_device_ScanFinished);
            
        _device.ShowUI = false;
        _device.DisableAfterAcquire = true;
            
        // open the device
        _device.Open();
            
        // set scanning settings
        _device.JobControl = JobControl.DetectAndIncludeJobSeparatorAndContinueScanning;
        _jobCounter = _jobCounter + 1;
            
        // acquire images from device
        _device.Acquire();
    }
    catch (TwainException ex)
    {
        Console.WriteLine(ex.Message);
    }
}
            
private void _device1_ImageAcquired(object sender, ImageAcquiredEventArgs e)
{
    if (_device.EndOfJob)
        _jobCounter = _jobCounter + 1;
    else
    {
        try
        {
            // save the acquired image
            e.Image.Save(string.Format(@"c:\job{0}.tif", _jobCounter));
            
            // dispose the acquired image
            e.Image.Dispose();
        }
        catch (ImagingException ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
}
            
private void _device1_ScanCompleted(object sender, EventArgs e)
{
    Console.WriteLine("Scan is completed.");
}
            
private void _device1_ScanCanceled(object sender, EventArgs e)
{
    Console.WriteLine("Scan is canceled.");
}
            
private void _device1_ScanFailed(object sender, ScanFailedEventArgs e)
{
    Console.WriteLine(string.Format("Scan is failed: {0}", e.ErrorString));
}
            
void _device_ScanFinished(object sender, EventArgs e)
{
    // 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
Open Method
EndOfJob Property
GetSupportedJobControlValues Method