Exemple #1
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));
                ISvnClientPool   pool        = GetService <ISvnClientPool>();
                IAnkhDialogOwner dialogOwner = GetService <IAnkhDialogOwner>();

                using (ProgressDialog dialog = new ProgressDialog())
                    using (SvnClient client = pool.GetClient())
                        using (CreateUpdateReport ? BindOutputPane(client) : null)
                            using (dialog.Bind(client))
                            {
                                _sync          = dialog;
                                dialog.Caption = caption;
                                dialog.Context = this;
                                thread.Name    = "AnkhSVN Worker";
                                bool threadStarted = false;

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

                                do
                                {
                                    if (!_closed)
                                    {
                                        dialog.ShowDialog(this);
                                    }
                                    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);
                }
            }