public static CredentialsPromptResult PromptForCredentials(ref string username, ref string password, ICredentialsDomain domain)
        {
            CredentialsPromptResult result;

            if (BlogClientUIContext.SilentModeForCurrentThread)
            {
                return(CredentialsPromptResult.Abort);
            }

            IBlogClientUIContext uiContext = BlogClientUIContext.ContextForCurrentThread;

            if (uiContext != null)
            {
                PromptHelper promptHelper = new PromptHelper(uiContext, username, password, domain);
                if (uiContext.InvokeRequired)
                {
                    uiContext.Invoke(new InvokeInUIThreadDelegate(promptHelper.ShowPrompt), new object[0]);
                }
                else
                {
                    promptHelper.ShowPrompt();

                    //force a UI loop so that the dialog closes without hanging while post-dialog logic executes
                    Application.DoEvents();
                }

                result = promptHelper.Result;
                if (result != CredentialsPromptResult.Cancel)
                {
                    username = promptHelper.Username;
                    password = promptHelper.Password;
                }
            }
            else
            {
                result = CredentialsPromptResult.Abort;
            }
            return(result);
        }
        public static DialogResult ShowDisplayMessageOnUIThread(MessageId messageId, params object[] parameters)
        {
            IBlogClientUIContext uiContext = ContextForCurrentThread;

            if (uiContext == null)
            {
                Trace.Fail("BlogClientUIContext.ShowDisplayMessageOnUIThread called without a context in scope!");
                return(DialogResult.None);
            }

            DisplayMessageHelper dmh = new DisplayMessageHelper(uiContext, messageId, parameters);

            if (uiContext.InvokeRequired)
            {
                uiContext.Invoke(new ThreadStart(dmh.Handler), null);
            }
            else
            {
                dmh.Handler();
            }
            return(dmh.DialogResult);
        }