private async void Bttn3_Click(object sender, RoutedEventArgs e) { var cancelSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); cancelSource.Token.ThrowIfCancellationRequested(); Task t = DemonstrationMethods.WrapSynchronousInAsynchronousMethod(cancelSource.Token); StatusBlock.Text = "Finished - Synchronous on separate thread"; }
private async void Bttn6_Click(object sender, RoutedEventArgs e) { DemonstrationMethods.SynchronousTemporaryContextRemovalMethod(); StatusBlock.Text = "Finished - Synchronous using safe getter"; }
private async void Bttn5_Click(object sender, RoutedEventArgs e) { DemonstrationMethods.SynchronousUsingStephenClearyMethod(); StatusBlock.Text = "Finished - Synchronous using Stephen Cleary method"; }
private async void Bttn4_Click(object sender, RoutedEventArgs e) { DemonstrationMethods.SynchronousWithNoCapturedContinuationMethod(); StatusBlock.Text = "Finished - Synchronous without captured context"; }
private async void Bttn2_Click(object sender, RoutedEventArgs e) { await DemonstrationMethods.AsyncAllTheWayDownMethod(); StatusBlock.Text = "Finished - Asynchronous"; }
private async void Bttn1_Click(object sender, RoutedEventArgs e) { DemonstrationMethods.FullySynchronousMethod(); StatusBlock.Text = "Finished - Synchronous - DEADLOCK!"; }