From ac7b0479839ef43b3bcda44bcd8d5040bcfdaac3 Mon Sep 17 00:00:00 2001 From: Tracy Pearson Date: Fri, 12 Aug 2022 01:32:31 -0400 Subject: [PATCH] It does not need the async/await --- WpfViewModelFirst/MainWindowViewModel.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WpfViewModelFirst/MainWindowViewModel.cs b/WpfViewModelFirst/MainWindowViewModel.cs index f4e8344..db5fa43 100644 --- a/WpfViewModelFirst/MainWindowViewModel.cs +++ b/WpfViewModelFirst/MainWindowViewModel.cs @@ -27,11 +27,16 @@ namespace WpfViewModelFirst private void Part1Action() { CurrentViewModel = null; - Task.Run(async () => await LongDelay()).ContinueWith(c => - { - System.Diagnostics.Debug.WriteLine(c.Result); - CurrentViewModel = new Part2ViewModel(); + Task delay = Task.Run(LongDelay).ContinueWith(c => + { + System.Diagnostics.Debug.WriteLine(c.Result); + CurrentViewModel = new Part2ViewModel(); }, TaskContinuationOptions.OnlyOnRanToCompletion); + //Task.Run(async () => await LongDelay()).ContinueWith(c => + // { + // System.Diagnostics.Debug.WriteLine(c.Result); + //CurrentViewModel = new Part2ViewModel(); + //}, TaskContinuationOptions.OnlyOnRanToCompletion); } private async Task LongDelay()