【发布时间】:2021-03-07 02:13:56
【问题描述】:
有没有办法同步使用restsharp?我在 Visual Studio 中看到的每个方法都有“异步”后缀和 restsharp 主页,(有以下示例):
// execute the request
RestResponse response = client.Execute(request);
var content = response.Content; // raw content as string
明确区分同步和异步请求:
// easy async support
client.ExecuteAsync(request, response => {
Console.WriteLine(response.Content);
});
如何访问此“执行”同步方法?
【问题讨论】:
-
我安装了 Restsharp,但无法访问“执行”方法,有什么想法吗?
-
检查这个restsharp.dev/v107 "...所有同步方法都消失了。如果您绝对必须在不使用 async 和 await 的情况下调用,请使用 GetAwaiter().GetResult() 阻塞调用..."
标签: c# httpwebrequest restsharp