Ejemplo n.º 1
0
        /// <summary>
        /// 작업을 다른 스레드에서 실행하고 프로세스 창을 엽니다.
        /// </summary>
        public static void Run(Action action, bool isCancelable, bool isProgressBar)
        {
            var vProgress = new VMProgressDialog(
                (isCancelable == true) ? Cancelable.Yes : Cancelable.No,
                (isProgressBar == true) ? IsProgress.Yes : IsProgress.No);
            var wProgress = new ProgressDialog(vProgress);

            ProgressManager.Initialize();
            Exception exception = null;

            Task.Factory.StartNew(() => {
                try {
                    Thread.Sleep(100);
                    action();
                }
                catch (Exception ex) {
                    exception = ex;

                    return;
                }
            }, ProgressManager.CancellationToken).ContinueWith(w => {
                wProgress.Close();
            }, TaskScheduler.FromCurrentSynchronizationContext());
            wProgress.ShowDialog();
            if (exception != null)
            {
                if (exception is OperationCanceledException)
                {
                    return;
                }
                throw exception;
            }
        }
Ejemplo n.º 2
0
        internal ProgressDialog(VMProgressDialog viewModel)
        {
            InitializeComponent();

            Owner = Application.Current.MainWindow;

            DataContext = viewModel;
        }