【发布时间】:2019-02-08 05:39:14
【问题描述】:
我在异步方法中返回变量时遇到问题。我能够让代码执行,但我无法让代码返回电子邮件地址。
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
}
【问题讨论】:
标签: c# .net asynchronous restsharp