Exemple #1
0
        public static StuckUILoadingWindow Loading(string message)
        {
            var view = new StuckUILoadingWindow();

            view.Show();
            view.tbCaption.Text = message;
            view.progressView.StartProgress();
            return(view);
        }
        public static void Show(string message, Action target)
        {
            var dispatcher  = System.Windows.Threading.Dispatcher.CurrentDispatcher;
            var newUiThread = new Thread(() => {
                var view            = new StuckUILoadingWindow();
                view.tbCaption.Text = message;
                view.progressView.StartProgress();
                view.ContentRendered += (o, e) =>
                {
                    dispatcher.BeginInvoke(new Action(() => {
                        target?.Invoke();
                        view.Dispatcher.BeginInvoke(new Action(view.Close));
                    }));
                };
                view.ShowDialog();
                System.Windows.Threading.Dispatcher.Run();
            });

            newUiThread.IsBackground = true;
            newUiThread.SetApartmentState(ApartmentState.STA);
            newUiThread.Start();
        }