安装的版本
NuGet\Install-Package RestSharp -Version 106.12.0
代码如下
internal class Program
{
static void Main(string[] args)
{
语音实体 x = new 语音实体();
x.text = "重量" + 32 + "公斤,请下磅";
Thread thread = new Thread(() => 发送语音(x));
thread.Start();
Console.ReadKey();
}
private static void 发送语音(语音实体 x)
{
var client = new RestClient("http://10.30.25.234/v1/speech");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(x);
var response = client.Execute<dynamic>(request);
Console.WriteLine(response.Content);
}
多线程中调用此方法
Thread thread = new Thread(() => 发送语音(x));
thread.Start();
标签:最简,thread,Thread,代码,request,语音,var,new,RestSharp From: https://www.cnblogs.com/hlm750908/p/18367193