NanoByte.Common.Tasks.DialogTaskHandler.RunTask C# (CSharp) Method

RunTask() public method

public RunTask ( ITask task ) : void
task ITask
return void
        public override void RunTask(ITask task)
        {
            #region Sanity checks
            if (task == null) throw new ArgumentNullException(nameof(task));
            #endregion

            Log.Debug("Task: " + task.Name);
            ApplicationUtils.Invoke(() =>
            {
                using (var dialog = new TaskRunDialog(task, CredentialProvider, CancellationTokenSource, _owner))
                {
                    dialog.Execute();
                    if (dialog.Exception != null) throw dialog.Exception.PreserveStack();
                }
            });
        }

Usage Example

コード例 #1
0
ファイル: SyncWizard.cs プロジェクト: 0install/0install-win
        private void pageExistingCryptoKey_Commit(object sender, WizardPageConfirmEventArgs e)
        {
            _cryptoKey = textBoxCryptoKey.Text;

            try
            {
                using (var handler = new DialogTaskHandler(this))
                    handler.RunTask(new SimpleTask(Text, CheckCryptoKey));
            }
                #region Error handling
            catch (WebException ex)
            {
                Log.Warn(ex);
                Msg.Inform(this, ex.Message, MsgSeverity.Warn);
                e.Cancel = true;
            }
            catch (InvalidDataException ex)
            {
                Log.Warn(ex);
                Msg.Inform(this, ex.Message, MsgSeverity.Warn);
                e.Cancel = true;
            }
            catch (OperationCanceledException)
            {
                e.Cancel = true;
            }
            #endregion

            pageExistingCryptoKey.NextPage = _troubleshooting ? pageChangeCryptoKey : pageSetupFinished;
        }
All Usage Examples Of NanoByte.Common.Tasks.DialogTaskHandler::RunTask