示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskProgress"/> class with the specified
        /// description, task, cancellation token source, and progress tracker.
        /// </summary>
        /// <param name="title">The title for the progess pop-up.</param>
        /// <param name="description">The description of the task.</param>
        /// <param name="task">The task.</param>
        /// <param name="cancellationTokenSource">The cancellation token source that cancels the task.</param>
        /// <param name="progressTracker">The progress tracker that tracks the task's progress.</param>
        /// <exception cref="ArgumentNullException"><paramref name="description"/> or <paramref name="task"/> is <c>null</c>.</exception>
        public TaskProgress(string title, string description, Task task, CancelStopAbort cancelStopAbortTokensSource, ProgressTracker progressTracker, bool isAssay)
        {
            if (description == null || task == null)
            {
                throw new ArgumentNullException();
            }

            m_stopCommand   = new CancelCommand(cancelStopAbortTokensSource.StopTokenSource, 0);
            m_cancelCommand = new CancelCommand(cancelStopAbortTokensSource.CancellationTokenSource, 1);
            m_abortCommand  = new CancelCommand(cancelStopAbortTokensSource.AbortTokenSource, 2); // make an enum!

            m_description             = description;
            m_isProgressIndeterminate = true;
            m_progress        = 0;
            m_progressTracker = progressTracker;
            m_task            = task;
            m_title           = title;
            m_isAssay         = isAssay;

            if (m_progressTracker != null)
            {
                m_progressTracker.ProgressChanged += (sender, e) => {
                    IsProgressIndeterminate = false;
                    Progress    = e.ProgressPercentage;
                    Description = (string)e.UserState;
                };
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskProgress"/> class with the specified
        /// description, task, cancellation token source, and progress tracker.
        /// </summary>
        /// <param name="title">The title for the progess pop-up.</param>
        /// <param name="description">The description of the task.</param>
        /// <param name="task">The task.</param>
        /// <param name="cancellationTokenSource">The cancellation token source that cancels the task.</param>
        /// <param name="progressTracker">The progress tracker that tracks the task's progress.</param>
        /// <exception cref="ArgumentNullException"><paramref name="description"/> or <paramref name="task"/> is <c>null</c>.</exception>
        public TaskProgress(string title, string description, Task task, CancelStopAbort cancelStopAbortTokensSource, ProgressTracker progressTracker, bool isAssay)
        {
            if (description == null || task == null) {
                throw new ArgumentNullException();
            }

            m_stopCommand = new CancelCommand(cancelStopAbortTokensSource.StopTokenSource, 0);
            m_cancelCommand = new CancelCommand(cancelStopAbortTokensSource.CancellationTokenSource, 1);
            m_abortCommand = new CancelCommand(cancelStopAbortTokensSource.AbortTokenSource, 2);  // make an enum!

            m_description = description;
            m_isProgressIndeterminate = true;
            m_progress = 0;
            m_progressTracker = progressTracker;
            m_task = task;
            m_title = title;
            m_isAssay = isAssay;

            if (m_progressTracker != null) {
                m_progressTracker.ProgressChanged += (sender, e) => {
                    IsProgressIndeterminate = false;
                    Progress = e.ProgressPercentage;
                    Description = (string)e.UserState;
                };
            }
        }