Exemplo n.º 1
0
 internal static bool OperationToProgress(IOperation operation, CDriver.Progress progress, int min, int max)
 {
     while (operation.Status == 0)
     {
         int num;
         if (operation.Max > operation.Min)
         {
             num = (max - min) * (operation.Current - operation.Min) / (operation.Max - operation.Min);
         }
         else
         {
             num = (min + max) / 2;
         }
         if (num == 0)
         {
             num = 1;
         }
         if (!progress(num))
         {
             operation.Cancel();
             operation.Wait();
             return(false);
         }
         Thread.Sleep(100);
     }
     if (operation.Status == 1)
     {
         return(true);
     }
     throw new Exception("Item number : " + ((operation.Result != null) ? operation.Result.ToString() : "0") + " HRESULT : " + operation.Error.ToString());
 }
Exemplo n.º 2
0
        protected override void OnExit(ExitEventArgs e)
        {
            mApplication?.Cancel();
            mRunningScope.Leave();

            // ReSharper disable once ConstantConditionalAccessQualifier
            if (mApplication?.ExecutionResult?.HasError ?? false)
            {
                e.ApplicationExitCode = -1;
            }

            base.OnExit(e);

            mApplication = null;
            mViewModel   = null;
            MainWindow   = null;
        }
Exemplo n.º 3
0
 private void cancelToolStripMenuItem_Click(object sender, EventArgs e)
 {
     op.Cancel();
     cancelToolStripMenuItem.Enabled = false;
 }