コード例 #1
0
        private void Worker_RunWorkerCompleted(object?sender, RunWorkerCompletedEventArgs e)
        {
            LOG.Debug($"{nameof( Worker_RunWorkerCompleted )} - Elapsed Time: {DateTime.Now - _start}");

            ElapsedUpdateTimer.Stop();

            if (e.Error != null)
            {
                LogOutput(Environment.NewLine + $"An error occurred while running the tasks:{Environment.NewLine}{e.Error}", Color.Red);
                this.ProgressBar.SetState(Native.ProgressBarState.Error);
            }

            if (!_cancel)
            {
                LogOutput(Environment.NewLine + this.CompletedText, CompletedTextColor);
            }
            else
            {
                LogOutput(Environment.NewLine + "Cancelled", CancelledTextColor);
            }
            Cancel.Text    = "Close";
            Cancel.Enabled = true;

            this.Completed = true;
            OnProgressCompleted(EventArgs.Empty);
        }
コード例 #2
0
        public void DoProgress()
        {
            if (_started)
            {
                throw new InvalidOperationException("Progress has already been started");
            }

            if (!this.IsHandleCreated)
            {
                this.CreateHandle();
            }

            if (!_cancel)
            {
                _started = true;
                _start   = DateTime.Now;
                ElapsedUpdateTimer.Start();
                Worker.RunWorkerAsync();
            }
        }