public static void AssignTask(IProgressDialogController progress, ITask task)
        {
            var taskManager = new TaskManager(task.Name);

            taskManager.Enqueue(task);

            var progressChangedHandler = new EventHandler((o, e) =>
            {
                progress.SetProgress(taskManager.Progress);
                if (ProgressScope.ProgressEquals(taskManager.Progress, 1.0))
                {
                    progress.CloseAsync();
                }
            });
            var statusMessageChangedHandler = new EventHandler((o, e) => progress.SetMessage(taskManager.StatusMessage));
            var isIndetermineChangedHandler = new EventHandler((o, e) => { if (taskManager.IsIndeterminate)
                                                                           {
                                                                               progress.SetIndeterminate();
                                                                           }
                                                               });

            taskManager.ProgressChanged      += progressChangedHandler;
            taskManager.StatusMessageChanged += statusMessageChangedHandler;
            taskManager.IsIndetermineChanged += isIndetermineChangedHandler;

            taskManager.Process().Wait();

            taskManager.ProgressChanged      -= progressChangedHandler;
            taskManager.StatusMessageChanged -= statusMessageChangedHandler;
            taskManager.IsIndetermineChanged -= isIndetermineChangedHandler;
        }
Exemplo n.º 2
0
        void ProgressBarAnimation_Completed(object sender, EventArgs e)
        {
            if (ProgressScope.ProgressEquals(this.ViewModel.LoadingProgress, 1.0))
            {
                this.ViewModel.LoadingIsIndeterminate = true;
                this.ViewModel.LoadingStatusText      = this.L("splash", "status_preparing");
            }

            _progressBarAnimation.Completed -= ProgressBarAnimation_Completed;
            _progressBarAnimation            = null;
        }
Exemplo n.º 3
0
        void taskManager_ProgressChanged(object sender, EventArgs e)
        {
            var taskManager = (TaskManager)sender;

            _activeTaskManager = taskManager;

            if (ProgressScope.ProgressEquals(taskManager.Progress, 1.0))
            {
                this.RemoveTaskManager(taskManager);
            }
        }