在 WPF 应用程序 (F10) 中,一个可等待的方法会将您带到下一行,但在 xamarin android 项目中,它的行为并非如此(就像我按下了 F5 一样),我不得不在上放置一个断点下一行以便正确调试 - 这太麻烦了 - 。
async Task SomeMethod()
{
await Task.Delay(1000); <--------- Stepping over this line leaves the function.
int x = 1; <--------- I have to add a breakpoint here.
}
这是一个错误还是一个功能?
PS:我使用的是 Visual Studio 2017。
最佳答案
确保您的方法是异步的。测试了我的,它在我身边工作。下面的例子:-
Task.Run(async () =>
{
await Task.Delay(1000);
int x = 1;
});
或者
async Task YourMethod
{
await Task.Delay(1000);
int x = 1;
}
关于debugging - Xamarin 跳过了一个可等待的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44546657/