安裝的版本
NuGet\Install-Package RestSharp -Version 106.15.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();