示例#1
0
文件: FBatchScan.cs 项目: gas3/twain
        private async Task DoBatchScan()
        {
            try
            {
                await batchScanPerformer.PerformBatchScan(BatchSettings, this,
                                                          image => SafeInvoke(() => ImageCallback(image)), ProgressCallback, cts.Token);

                SafeInvoke(() =>
                {
                    lblStatus.Text = cts.IsCancellationRequested
                        ? MiscResources.BatchStatusCancelled
                        : MiscResources.BatchStatusComplete;
                });
            }
            catch (ScanDriverException ex)
            {
                if (ex is ScanDriverUnknownException)
                {
                    Log.ErrorException("Error in batch scan", ex);
                    errorOutput.DisplayError(ex.Message, ex);
                }
                else
                {
                    errorOutput.DisplayError(ex.Message);
                }
            }
            catch (Exception ex)
            {
                Log.ErrorException("Error in batch scan", ex);
                errorOutput.DisplayError(MiscResources.BatchError, ex);
                SafeInvoke(() =>
                {
                    lblStatus.Text = MiscResources.BatchStatusError;
                });
            }
            SafeInvoke(() =>
            {
                batchRunning      = false;
                cts               = new CancellationTokenSource();
                btnStart.Enabled  = true;
                btnCancel.Enabled = true;
                btnCancel.Text    = MiscResources.Close;
                EnableDisableSettings(true);
                Activate();
            });
        }
示例#2
0
文件: FBatchScan.cs 项目: sicmx/naps2
 private void DoBatchScan()
 {
     try
     {
         batchScanPerformer.PerformBatchScan(BatchSettings, this,
                                             image => Invoke(() => ImageCallback(image)), ProgressCallback());
         Invoke(() =>
         {
             lblStatus.Text = cancelBatch
                 ? MiscResources.BatchStatusCancelled
                 : MiscResources.BatchStatusComplete;
         });
     }
     catch (ScanDriverException ex)
     {
         if (ex is ScanDriverUnknownException)
         {
             Log.ErrorException("Error in batch scan", ex);
             errorOutput.DisplayError(ex.Message, ex);
         }
         else
         {
             errorOutput.DisplayError(ex.Message);
         }
     }
     catch (Exception ex)
     {
         Log.ErrorException("Error in batch scan", ex);
         errorOutput.DisplayError(MiscResources.BatchError, ex);
         Invoke(() =>
         {
             lblStatus.Text = MiscResources.BatchStatusError;
         });
     }
     Invoke(() =>
     {
         batchRunning      = false;
         cancelBatch       = false;
         btnStart.Enabled  = true;
         btnCancel.Enabled = true;
         btnCancel.Text    = MiscResources.Close;
         EnableDisableSettings(true);
         Activate();
     });
 }