Esempio n. 1
0
        public static void DoBackgroundWorkWithSplash(IWin32Window sender, DoWorkEventHandler workToDo,
            string splashText, bool singleThreadApartment = false)
        {
            var loadingSplash = new FrmLoadingSplash {StartPosition = FormStartPosition.CenterParent};
            loadingSplash.SetTitle(splashText);

            var thread = new Thread(() =>
            {
                workToDo(null, null);
                loadingSplash.WorkCompleted();
            });
            if (singleThreadApartment)
                thread.SetApartmentState(ApartmentState.STA);
            thread.Start();

            loadingSplash.ShowDialog(sender);
        }
Esempio n. 2
0
        public static void DoBackgroundWorkWithSplash(IWin32Window sender, DoWorkEventHandler workToDo,
                                                      string splashText)
        {
            var loadingSplash = new FrmLoadingSplash {
                StartPosition = FormStartPosition.CenterParent
            };

            loadingSplash.SetTitle(splashText);

            var updateThread = new BackgroundWorker();

            updateThread.DoWork             += workToDo;
            updateThread.RunWorkerCompleted += (o, e) => { loadingSplash.WorkCompleted(); };

            updateThread.RunWorkerAsync();
            loadingSplash.ShowDialog(sender);
        }