Beispiel #1
0
        private void MainWindow_FinishedWork(Object sender, DownloadStats e)
        {
            // This is what happens when that event "FinishedWork" (a little below) is invoked
            Dispatcher.Invoke(() =>
            {
                if (e.WasCancelled == false)
                {
                    WriteToLog("Finished task.");
                }
                else
                {
                    WriteToLog("Task was cancelled.");
                }

                MessageBox.Show(this, $"Download {(e.WasCancelled ? "was cancelled." : "finished.")}\n\n" +
                                $"A total of {e.PostsFound} posts was found and {e.PostsDownloaded} posts were downloaded.",
                                "Download info", MessageBoxButton.OK, MessageBoxImage.Information);

                ToggleControls(true);
                btnStartDownload.Content = "Start Download";

                CancelRequested            = false;
                btnStartDownload.IsEnabled = true;
            });
        }
Beispiel #2
0
 public void UpdateETA(DownloadStats stats, bool onlyFound = false, bool finished = false)
 {
     Dispatcher.Invoke(() =>
     {
         txtETA.Inlines.Clear();
         txtETA.Inlines.Add(new Run("Remaining (ETA): "));
         if (RegisteredTimestamps.Count < 3)
         {
             txtETA.Inlines.Add(new Run($"{(finished ? "-" : (onlyFound ? "Not yet downloading." : $"{"Calculating..."}"))}")
             {
                 FontWeight = FontWeights.Bold
             });
         }