public static DialogResult ExecuteWithProgress(string title, ProgressOperation operation, ISynchronizeInvoke synchronizeInvoke, IWin32Window owner)
        {
            using (ProgressDialog progress = new ProgressDialog())
            {
                progress.Text = title;
                MultipartAsyncOperation async = new MultipartAsyncOperation(synchronizeInvoke);
                async.AddProgressOperation(operation, new ProgressCategory(null, null), 100);
                progress.ProgressProvider = async;
                async.Start();

                DialogResult result;
                if (!async.IsDone)
                    result = progress.ShowDialog(owner);
                else
                    result = progress.DialogResult;

                if (result == DialogResult.Cancel)
                    throw new OperationCancelledException();
                else if (result == DialogResult.Abort)
                    throw async.Exception;
                else
                    return result;
            }
        }
        private void buttonAutoDetectWeblog_Click(object sender, System.EventArgs e)
        {
            try
            {
                textBoxResults.Text = String.Empty ;

                BlogAccountDetector accountDetector = new BlogAccountDetector(this, this.weblogHomepageUrlControl.HomepageUrl, this.textBoxUsername.Text, this.textBoxPassword.Text);

                // setup the progress dialog and kick off the transfer
                using (ProgressDialog progress = new ProgressDialog())
                {
                    // configure progress source
                    progress.ProgressProvider = accountDetector;

                    // set progress title
                    progress.Title = Text;
                    progress.ProgressText = Text ;

                    // start the publisher (this is a non-blocking call)
                    accountDetector.Start();

                    // show the progress dialog
                    progress.ShowDialog(this);
                }

                // show error
                if ( accountDetector.ErrorOccurred )
                {
                    accountDetector.ShowLastError(this);
                }
                else if (!accountDetector.WasCancelled)// ran to completion
                {
                    StringBuilder resultsBuilder = new StringBuilder();
                    resultsBuilder.AppendFormat( "Service: {0}\r\nClientApi: {1}\r\nPost URL: {2}\r\nBlogID: {3}\r\n\r\n",
                        accountDetector.ServiceName,
                        accountDetector.ClientType,
                        accountDetector.PostApiUrl,
                        accountDetector.BlogId ) ;

                    foreach ( BlogInfo blog in accountDetector.UsersBlogs )
                        resultsBuilder.AppendFormat( "{0} ({1})\r\n", blog.HomepageUrl, blog.Id ) ;

                    textBoxResults.Text = resultsBuilder.ToString() ;
                }
            }
            catch(Exception ex)
            {
                UnexpectedErrorMessage.Show(ex);
            }
        }