1
This commit is contained in:
parent
8951857c44
commit
51301040c7
@ -1,5 +1,7 @@
|
|||||||
using Microsoft.Extension.Core;
|
using Microsoft.Extension.Core;
|
||||||
|
using Microsoft.Extension.Net;
|
||||||
using Microsoft.Extension.Net.ApiCommunication;
|
using Microsoft.Extension.Net.ApiCommunication;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Demo
|
namespace Demo
|
||||||
{
|
{
|
||||||
@ -19,6 +21,15 @@ namespace Demo
|
|||||||
Age = 18
|
Age = 18
|
||||||
});
|
});
|
||||||
return apiRespond;
|
return apiRespond;
|
||||||
|
}, IPHost.From("127.0.0.1:6666"), (state, exception) => {
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
this.richTextBox1.Text = "服务启动成功!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.richTextBox1.Text = exception.ToString();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,12 +37,15 @@ namespace Demo
|
|||||||
{
|
{
|
||||||
this.richTextBox1.Text = "";
|
this.richTextBox1.Text = "";
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
var ret = ApiCommunicationManager.Request<ApiRequest, ApiRespond>(new ApiRequest() {
|
var ret = ApiCommunicationManager.Request<ApiRequest, ApiRespond>(new ApiRequest() {
|
||||||
StationID = "zys"
|
StationID = "zys"
|
||||||
});
|
}, IPHost.From("127.0.0.1:6666"),5000);//目标主机&超时时间ms
|
||||||
|
stopwatch.Stop();
|
||||||
if (ret.IsSucess)
|
if (ret.IsSucess)
|
||||||
{
|
{
|
||||||
this.richTextBox1.Text = ret.Content.GetJsonString();
|
this.richTextBox1.Text = ret.Content.GetJsonString();
|
||||||
|
this.richTextBox1.Text += $"\r\n耗时{stopwatch.ElapsedMilliseconds}ms";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user