Пример #1
0
        public override void Cancel()
        {
            if (_worker != null)
            {
                if (_worker.IsBusy)
                {
                    _worker.CancelAsync();

                    // Wait for the ConsoleWorker to finish the download.
                    while (_worker.IsBusy)
                    {
                        // Keep UI messages moving, so the form remains
                        // responsive during the asynchronous operation.
                        MainApplication.DoEvents();
                    }
                }
            }
        }
Пример #2
0
        public void Cancel()
        {
            btnCancel.IsEnabled = false;

            if (_worker != null)
            {
                if (_worker.IsBusy)
                {
                    _worker.CancelAsync();

                    // Wait for the BackgroundWorker to finish the download.
                    while (_worker.IsBusy)
                    {
                        // Keep UI messages moving, so the form remains
                        // responsive during the asynchronous operation.
                        MainApplication.DoEvents();
                    }
                }
            }
        }