public UnbindDisposable(TransportProgressDialog dialog)
 {
     _dialog = dialog;
 }
Esempio n. 2
0
            /// <summary>
            /// Call this to start the operation.
            /// </summary>
            /// <param name="caption">The caption to use in the progress dialog.</param>
            public void Start(string caption)
            {
                Thread thread = new Thread(new ParameterizedThreadStart(this.Run));
                IGitClientPool pool = _context.GetService<IGitClientPool>();
                IVisualGitDialogOwner dialogOwner = _context.GetService<IVisualGitDialogOwner>();

                ProgressDialogBase dialog;

                if (TransportClientArgs != null)
                {
                    TransportProgressDialog transportDialog = new TransportProgressDialog();
                    transportDialog.ClientArgs = TransportClientArgs;
                    dialog = transportDialog;
                }
                else
                    dialog = new ProgressDialog();

                using (dialog)
                using (GitClient client = pool.GetClient())
                using (CreateUpdateReport ? BindOutputPane(client) : null)
                using (dialog.Bind(client))
                {
                    _sync = dialog;
                    dialog.Caption = caption;
                    dialog.Context = _context;
                    thread.Name = "VisualGit Worker";
                    bool threadStarted = false;

                    dialog.HandleCreated += delegate
                    {
                        if (!threadStarted)
                        {
                            threadStarted = true;
                            thread.Start(client);
                        }
                    };
                    _invoker = dialog;

                    do
                    {
                        if (!_closed)
                        {
                            dialog.ShowDialog(_context);
                        }
                        else
                            Application.DoEvents();

                        // Show the dialog again if the thread join times out
                        // Do this to handle the acase where the service wants to
                        // pop up a dialog before canceling.

                        // BH: Experienced this 2008-09-29 when our repository server
                        //     accepted http connections but didn't handle them in time
                    }
                    while (!thread.Join(2500));
                }
                if (_cancelled)
                {
                    // NOOP
                }
                else if (_exception != null)
                    throw new ProgressRunnerException(this._exception);
            }