簡體   English   中英

Active Directory圖客戶端:使用C#API刪除應用程序

[英]Active Directory Graph Client: Delete an Application using the C# API

下面有一個調用導致我的程序終止。 請告訴我為什么。

        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在評論中提到的那樣,問題不在於等待異步調用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM