小编Chr*_*ris的帖子

如何在 RestSharp 中使用 ExecuteAsync 返回变量

我在异步方法中返回变量时遇到问题。我能够获取要执行的代码,但无法获取返回电子邮件地址的代码。

    public async Task<string> GetSignInName (string id)
    {

        RestClient client = new RestClient("https://graph.windows.net/{tenant}/users");
        RestRequest request = new RestRequest($"{id}");
        request.AddParameter("api-version", "1.6");
        request.AddHeader("Authorization", $"Bearer {token}");
        //string emailAddress = await client.ExecuteAsync<rootUser>(request, callback);

        var asyncHandler = client.ExecuteAsync<rootUser>(request, response =>
        {
            CallBack(response.Data.SignInNames);
        });

        return "test"; //should be a variable
    }
Run Code Online (Sandbox Code Playgroud)

.net c# asynchronous restsharp

5
推荐指数
1
解决办法
7943
查看次数

标签 统计

.net ×1

asynchronous ×1

c# ×1

restsharp ×1