Пример #1
0
        /// <summary>
        /// Creates a new ProgressDialog on its own thread, with its own
        /// message pump.
        /// </summary>
        /// <param name="state"></param>
        private static void ProgressDialogThreadProc(object state)
        {
            ProgressDialogReference reference = state as ProgressDialogReference;

            Invariant.Assert(reference != null);

            reference.Form = new ProgressDialog(reference.Title, reference.Message);

            //Spawn a new message pump for this dialog
            System.Windows.Forms.Application.Run();
        }
Пример #2
0
        /// <summary>
        /// Creates an instance of the ProgressDialog in a new thread, returning a
        /// ProgressDialogReference wrapper which will eventually contain a valid
        /// reference to the dialog (when the dialog is actually instantiated.)
        /// </summary>
        /// <param name="title">The title to appear in the Titlebar of the dialog</param>
        /// <param name="message">The message to appear in the dialog</param>
        /// <returns></returns>
        public static ProgressDialogReference CreateThreaded(string title, string message)
        {
            ProgressDialogReference reference =
                new ProgressDialogReference(title, message);

            // Spin up a new thread
            Thread dialogThread = new Thread(
                new ParameterizedThreadStart(ProgressDialogThreadProc));

            // Start it, passing in our reference
            dialogThread.Start(reference);

            // Return the reference -- the Form inside will eventually point to
            // the dialog created in ProgressDialogThreadProc.
            return(reference);
        }