VintaSoft Twain .NET SDK 15.0: Documentation for .NET developer
Vintasoft.Twain Namespace / Device Class / JobControl Property
Syntax Exceptions Remarks Example Requirements SeeAlso
In This Topic
    JobControl Property (Device)
    In This Topic
    Allows multiple jobs in batch mode.
    Syntax
    'Declaration
    
    Public Property JobControl As 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 C#/VB.NET code shows how to detect job separators during scanning.

    
    Private _deviceManager As Vintasoft.Twain.DeviceManager
    Private _device As Vintasoft.Twain.Device
    Private _jobCounter As Integer = -1
    
    Public Sub ScanImageWithJobControl()
            Try
                    ' create and open device manager
                    _deviceManager = New Vintasoft.Twain.DeviceManager()
                    _deviceManager.Open()
    
                    ' get reference to the default device
                    _device = _deviceManager.DefaultDevice
                    ' subscribe to device events
                    AddHandler _device.ImageAcquired, New System.EventHandler(Of Vintasoft.Twain.ImageAcquiredEventArgs)(AddressOf _device1_ImageAcquired)
                    AddHandler _device.ScanCompleted, New System.EventHandler(AddressOf _device1_ScanCompleted)
                    AddHandler _device.ScanCanceled, New System.EventHandler(AddressOf _device1_ScanCanceled)
                    AddHandler _device.ScanFailed, New System.EventHandler(Of Vintasoft.Twain.ScanFailedEventArgs)(AddressOf _device1_ScanFailed)
                    AddHandler _device.ScanFinished, New System.EventHandler(AddressOf _device_ScanFinished)
    
                    _device.ShowUI = False
                    _device.DisableAfterAcquire = True
    
                    ' open the device
                    _device.Open()
    
                    ' set scanning settings
                    _device.JobControl = Vintasoft.Twain.JobControl.DetectAndIncludeJobSeparatorAndContinueScanning
                    _jobCounter = _jobCounter + 1
    
                    ' acquire images from device
                    _device.Acquire()
            Catch ex As Vintasoft.Twain.TwainException
                    System.Console.WriteLine(ex.Message)
            End Try
    End Sub
    
    Private Sub _device1_ImageAcquired(sender As Object, e As Vintasoft.Twain.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 System.Exception
                            System.Console.WriteLine(ex.Message)
                    End Try
            End If
    End Sub
    
    Private Sub _device1_ScanCompleted(sender As Object, e As System.EventArgs)
            System.Console.WriteLine("Scan is completed.")
    End Sub
    
    Private Sub _device1_ScanCanceled(sender As Object, e As System.EventArgs)
            System.Console.WriteLine("Scan is canceled.")
    End Sub
    
    Private Sub _device1_ScanFailed(sender As Object, e As Vintasoft.Twain.ScanFailedEventArgs)
            System.Console.WriteLine(String.Format("Scan is failed: {0}", e.ErrorString))
    End Sub
    
    Private Sub _device_ScanFinished(sender As Object, e As System.EventArgs)
            ' close the device
            _device.Close()
    End Sub
    
    
    
    Vintasoft.Twain.DeviceManager _deviceManager;
    Vintasoft.Twain.Device _device;
    int _jobCounter = -1;
    
    public void ScanImageWithJobControl()
    {
        try
        {
            // create and open device manager
            _deviceManager = new Vintasoft.Twain.DeviceManager();
            _deviceManager.Open();
    
            // get reference to the default device
            _device = _deviceManager.DefaultDevice;
            // subscribe to device events
            _device.ImageAcquired += new System.EventHandler<Vintasoft.Twain.ImageAcquiredEventArgs>(_device1_ImageAcquired);
            _device.ScanCompleted += new System.EventHandler(_device1_ScanCompleted);
            _device.ScanCanceled += new System.EventHandler(_device1_ScanCanceled);
            _device.ScanFailed += new System.EventHandler<Vintasoft.Twain.ScanFailedEventArgs>(_device1_ScanFailed);
            _device.ScanFinished += new System.EventHandler(_device_ScanFinished);
    
            _device.ShowUI = false;
            _device.DisableAfterAcquire = true;
    
            // open the device
            _device.Open();
    
            // set scanning settings
            _device.JobControl = Vintasoft.Twain.JobControl.DetectAndIncludeJobSeparatorAndContinueScanning;
            _jobCounter = _jobCounter + 1;
    
            // acquire images from device
            _device.Acquire();
        }
        catch (Vintasoft.Twain.TwainException ex)
        {
            System.Console.WriteLine(ex.Message);
        }
    }
    
    private void _device1_ImageAcquired(object sender, Vintasoft.Twain.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 (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
    }
    
    private void _device1_ScanCompleted(object sender, System.EventArgs e)
    {
        System.Console.WriteLine("Scan is completed.");
    }
    
    private void _device1_ScanCanceled(object sender, System.EventArgs e)
    {
        System.Console.WriteLine("Scan is canceled.");
    }
    
    private void _device1_ScanFailed(object sender, Vintasoft.Twain.ScanFailedEventArgs e)
    {
        System.Console.WriteLine(string.Format("Scan is failed: {0}", e.ErrorString));
    }
    
    void _device_ScanFinished(object sender, System.EventArgs e)
    {
        // close the device
        _device.Close();
    }
    
    

    Requirements

    Target Platforms: .NET 8, .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also