Task.Run() leaves a warning it will run synchronosly.
This commit is contained in:
@@ -80,7 +80,7 @@ namespace WpfViewModelFirst.Tests
|
||||
TaskCompletionSource<bool> taskCompletionSource = new();
|
||||
main.ItHappened += () => taskCompletionSource.SetResult(true);
|
||||
|
||||
Task.Run(() =>
|
||||
Task run = new(() =>
|
||||
{
|
||||
DispatcherFrame frame = new();
|
||||
frame.Dispatcher.Invoke(
|
||||
@@ -91,6 +91,7 @@ namespace WpfViewModelFirst.Tests
|
||||
});
|
||||
Dispatcher.PushFrame(frame);
|
||||
});
|
||||
run.Start();
|
||||
await taskCompletionSource.Task.WaitAsync(CancellationToken.None);
|
||||
Assert.IsType<Part2ViewModel>(main.CurrentViewModel);
|
||||
}
|
||||
@@ -104,7 +105,7 @@ namespace WpfViewModelFirst.Tests
|
||||
TaskCompletionSource<bool> taskCompletionSource = new();
|
||||
main.ItHappened += () => taskCompletionSource.SetResult(true);
|
||||
|
||||
Task.Run(() =>
|
||||
Task run = new(() =>
|
||||
{
|
||||
DispatcherFrame frame = new();
|
||||
frame.Dispatcher.Invoke(
|
||||
@@ -115,6 +116,7 @@ namespace WpfViewModelFirst.Tests
|
||||
});
|
||||
Dispatcher.PushFrame(frame);
|
||||
});
|
||||
run.Start();
|
||||
await taskCompletionSource.Task.WaitAsync(CancellationToken.None);
|
||||
Assert.Single(main.Strings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user