Active Directory图形客户端:使用c# API删除应用程序
本文关键字:API 删除 应用程序 使用 Directory 图形 客户端 Active | 更新日期: 2023-09-27 18:04:33
下面有一个调用导致我的程序终止。请告诉我为什么。
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();
}
正如Thomas在评论中提到的,问题不在于等待异步调用