下面有一个调用导致我的程序终止。请告诉我原因。
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
tcs.SetResult(accessToken);
ActiveDirectoryClient graphClient = new ActiveDirectoryClient(
new Uri($"https://graph.windows.net/{tenantId}"),
async () => { return await tcs.Task; });
// this part runs fine and I can see a list of applications being printed
foreach (var app in graphClient.Applications.ExecuteAsync().Result.CurrentPage)
{
Console.WriteLine($"{app.AppId}, {app.DisplayName}");
}
// this call causes the program to terminate
var matches = await graphClient.Applications
.Where(app => app.AppId == clientId)
.ExecuteAsync();
// the execution never gets to this part:
foreach (IApplication app in matches.CurrentPage.ToList())
{
await app.DeleteAsync();
}
答案 0 :(得分:0)
正如Thomas在评论中提到的那样,问题不在于等待异步调用