private static void HandleJobStateChanged(object sender, EventArgs e) { DataProcessingJob job = sender as DataProcessingJob; if (job == null) { return; } switch (job.State) { case JobState.Running: TextBlock textBlockStart = new TextBlock { Margin = "0 0 0 1", Text = "The job was started." }; textBlockStart.Display(); progressBar.Display(); break; case JobState.Stopped: progressBar.Close(); TextBlock textBlockFinish = new TextBlock { Margin = "0 1 0 0", Text = "The job was finished." }; textBlockFinish.Display(); break; } }
public void Show() { TextBlock textBlock = new TextBlock { Margin = "0 0 0 1", Text = "We create a DataProcessingJob object that will simulate some data processing." }; textBlock.Display(); job = new DataProcessingJob(); job.StateChanged += HandleJobStateChanged; job.ProgressChanged += HandleJobProgressChanged; job.Run(); }