How to wait in WIA CommonDialog.ShowAcquisitionWizard completion method?

I am trying to use WIA for scanning, and I ran into small problems. I use the CommonDialog.ShowAcquisitionWizard method, as described on MSDN . The problem is that the object is not returned from the method. I need to know when the scan is complete, and I tried several methods (Thread) and failed. Can someone suggest a method that I should use to determine if the scan is complete and / or the dialog is closing?

My current code is:

private void DoScan()
{
    WIA.CommonDialog dialog = new WIA.CommonDialog();
    Device device = dialog.ShowSelectDevice(WiaDeviceType.ScannerDeviceType);
    dialog.ShowAcquisitionWizard(device);

    // immediately jumps to this line...
    string test = "is it done?";

    // if i put a breakpoint there, the WIA interface never appears, I have to continue before it will show.
    // so a threading.sleep(5000) won't work...
}
+4
source share

All Articles