Ejemplo n.º 1
0
        /// <summary>
        /// Refresh button has been clicked.
        /// </summary>
        /// <param name="sender">Sender of event.</param>
        /// <param name="e">Event arguments.</param>
        private void OnRefreshClicked(object sender, EventArgs e)
        {
            refreshButton.IsEnabled = false;
            jobList.Clear();
            jobListView.ClearRows();

            Task.Run(() => cloudInterface.ListJobsAsync(cancelToken.Token,
                                                        p => UpdateProgressBar(p),
                                                        job => AddJobToView(job)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called from a background worker thread. Updates the list of cloud jobs
        /// by interrogating the cloud platform.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="args">Event arguments.</param>
        private async void ListJobs(object sender, DoWorkEventArgs args)
        {
            try
            {
                while (!fetchJobs.CancellationPending) // fixme
                {
                    // Update the list of jobs. This will take some time.
                    view.JobLoadProgress = 0;
                    view.ShowLoadingProgressBar();
                    var newJobs = await cloudInterface.ListJobsAsync(cancelToken.Token, p => view.JobLoadProgress = p);

                    if (fetchJobs.CancellationPending)
                    {
                        return;
                    }

                    if (Different(newJobs, jobList))
                    {
                        view.UpdateJobTable(newJobs);
                    }

                    jobList = newJobs;

                    view.HideLoadingProgressBar();

                    // Refresh job list every 10 seconds
                    Thread.Sleep(10000);
                }
            }
            catch (Exception err)
            {
                presenter.ShowError(err);
            }
            finally
            {
                view?.HideLoadingProgressBar();
            }
        }