progress and other problems.

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
czeshirecat
Posts: 1
Joined: Thu Feb 10, 2011 6:46 pm

progress and other problems.

Post by czeshirecat »

Visual Studio 2010, C# dot net 4.0, Vintasofttwain version 7.0.27.1 evaluation (until company processes order)
Epson Perfection scanner V30. Windows 7, enterprise, 32 bit.

I used your simple demo code with some extras to create a form to create a document scanner.

Problem 1.
If I set VintaSoftTwain device.ShowIndicators to true, the Vintasoft progress dialog pops up immediately the scanner begins to scan and it shows the progress correctly.
If I set showindicators to false and set up my own progress event, the event only starts after the scanner has finished scanning.
If I set showindicators to true, set up my own event (as an experiment), the Vintasoft progress pops up immediately during the scan, my own event arrives after the scan finishes.

Problem 2.
When I use the progress event, tracing through my code shows that eventually 100 is received but my visual studio progress bar only visually shows about 40%. (Min = 0, Max = 100) for the progress bar control.

Code: Select all

private void ImageAcquiringProgress(object sender, ImageAcquiringProgressEventArgs e)
    {
      #region ImageAcquiringProgress
      const string fnName = "ImageAcquiringProgress";
      try
      {
        if (!pbProgress.Visible)
        {
          pbProgress.Visible = true;
          pbProgress.BringToFront();
        }
        e.Cancel = _cancelScan;
        pbProgress.Value = e.Progress;
      }
      catch(Exception err)
      {
        LogException(fnName, err);
        throw;
      }
      #endregion
    }// function
Problem 3.
The image takes many seconds to appear in the picture box after acquisition. I expected it to arrive immediately after the call to "pic1.Image = _device.AcquiredImages.Last.GetAsBitmap(true);"
but its not. I put some debug statements around this line and it passed through the line of code in 6ms so that's fine. It's such a long enough period that I know the user of the software will wonder what's going wrong. All the events to say the scan have finished have arrived, the status texts and buttons on my form says it's idle, but Im aware that the messages for clicking buttons are being held up in message queue as I get no animation of my buttons.

Code: Select all

private void DeviceImageAcquired(object sender, ImageAcquiredEventArgs e)
    {
      #region DeviceImageAcquired
      const string fnName = "DeviceImageAcquired";
      try
      {
        if (_device.AcquiredImages.Count > 0)
        {
          if (pic1.Image != null)
          {
            pic1.Image.Dispose();
            pic1.Image = null;
          }
          pic1.Image = _device.AcquiredImages.Last.GetAsBitmap(true);
          cmdOk.Enabled = true;
        }
      }
      catch(Exception err)
      {
        LogException(fnName, err);
        frmWarning.ShowError(this,err);
      }
      #endregion
    }// function
A general query.
If this is set up as asynchronous using _device.Acquire() , is the scanning etc being run in its own thread? Because it's not really running asynchronously at the moment. My timer messages stop (I wanted an animation running while the scan was taking place which doesn't work), buttons within my window are unuseable etc.
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: progress and other problems.

Post by Alex »

Hello,
Problem 1.
If I set VintaSoftTwain device.ShowIndicators to true, the Vintasoft progress dialog pops up immediately the scanner begins to scan and it shows the progress correctly.
If I set showindicators to false and set up my own progress event, the event only starts after the scanner has finished scanning.
If I set showindicators to true, set up my own event (as an experiment), the Vintasoft progress pops up immediately during the scan, my own event arrives after the scan finishes.
Drivers are divided by 2 categories:
  • Drivers which send image data to the application right after the data are received from device - in this case driver progress and your progress will be synchronous
  • Drivers which receive image data from the scanner, process the image data and only then send image data to the application - in this case the driver progress will be the first and your progress will be the second.
Most of Epson scanners are the scanners of the first type.

What driver do you use? TWAIN or WIA? I think you are using WIA driver, try to use TWAIn driver instead.

When I use the progress event, tracing through my code shows that eventually 100 is received but my visual studio progress bar only visually shows about 40%. (Min = 0, Max = 100) for the progress bar control.
Progress "quality" also depends from the scanner but you always should receive 0 and 100 values.

Problem 3.
The image takes many seconds to appear in the picture box after acquisition. I expected it to arrive immediately after the call to "pic1.Image = _device.AcquiredImages.Last.GetAsBitmap(true);"
but its not. I put some debug statements around this line and it passed through the line of code in 6ms so that's fine. It's such a long enough period that I know the user of the software will wonder what's going wrong. All the events to say the scan have finished have arrived, the status texts and buttons on my form says it's idle, but Im aware that the messages for clicking buttons are being held up in message queue as I get no animation of my buttons.
What driver do you use? What is size and type of your images?

A general query.
If this is set up as asynchronous using _device.Acquire() , is the scanning etc being run in its own thread? Because it's not really running asynchronously at the moment. My timer messages stop (I wanted an animation running while the scan was taking place which doesn't work), buttons within my window are unuseable etc.
Scanning is running in the application thread.

Please read about the AcquireModal method and try to run scanning in the separate thread if this is necessary.

Best regards, Alexander
Post Reply