title: Scanning with WIA automatic feeder scanner fails for second page
body: <p>I'm trying to scan multiple pages using a scanner which has an automatic feeder. My code is very simple at the moment:</p>
  
  <pre><code>WIA.CommonDialog dialog = new WIA.CommonDialog();
  WIA.Device device = dialog.ShowSelectDevice(WIA.WiaDeviceType.ScannerDeviceType);
  WIA.Items items = dialog.ShowSelectItems(device);
  foreach (WIA.Item item in items)
  {
      while (true)
      {
          try
          {
              WIA.ImageFile image = (WIA.ImageFile)dialog.ShowTransfer(item);
              if (image != null &amp;&amp; image.FileData != null)
              {
                  dynamic binaryData = image.FileData.get_BinaryData();
                  if (binaryData is byte[])
                      using (MemoryStream stream = new MemoryStream(binaryData))
                      using (Bitmap bitmap = (Bitmap)Bitmap.FromStream(stream))
                      {
                          bitmap.Save(@"C:\Temp\scan.jpg", ImageFormat.Jpeg);
                      }
              }
          }
          catch (COMException)
          {
              break;
          }
      }
  }
  </code></pre>
  
  <p>I tried querying the <code>WIA_DPS_DOCUMENT_HANDLING_STATUS</code> property to see if there are any pages available in the feeder, but that always returns 1, so instead I'm catching a COM exception an if I get the <code>WIA_ERROR_PAPER_EMPTY</code>, I know that the document feeder is empty.</p>
  
  <p>The trouble is that this code only scans the first page, when the <code>dialog.ShowTransfer</code> method is called again, I get an exception with and <code>E_FAIL</code> HResult and I can't scan any more pages. Strangely enough, when I step through this code in the debugger, everything works fine and all pages are scanned.</p>
  
  <p>I tried freeing up the image object by doing <code>Marshal.ReleaseComObject(image)</code> and <code>image = null</code>, but that didn't help. Neither did the suggestions from <a href="https://stackoverflow.com/questions/6121151/c-sharp-wia-image-scanning-fails-with-hresult-0x80070050">this question</a>. Is there anything I'm doing wrong that's causing these errors?</p>
  
  <p>EDIT: I wasn't able to find a good solution for this. The scanner keeps throwing <code>E_FAIL</code> while the feeder is getting ready to scan the next page, which takes a couple of seconds (it is not a very fast scanner). So, I added a loop to keep trying for 10 seconds, which is a solution that I don't like, but it seems to work.</p>
  
  <p>EDIT 2: This seems to be an issue with the printer's WIA driver. I tried this with a different brand printer and it didn't have this problem at all.</p>