同步探测本地星尘代理时,捕获超时异常,避免误导用户以为其它业务功能异常
This commit is contained in:
parent
fc1a6d02d8
commit
c97c8239f7
|
@ -60,7 +60,7 @@ namespace Stardust
|
|||
/// <returns></returns>
|
||||
public AgentInfo GetInfo()
|
||||
{
|
||||
var task = GetInfoAsync();
|
||||
var task = GetInfoAsync().ContinueWith<AgentInfo>(t => null, TaskContinuationOptions.OnlyOnFaulted);
|
||||
if (task.Wait(500)) return task.Result;
|
||||
|
||||
return null;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Test
|
|||
{
|
||||
XTrace.UseConsole();
|
||||
|
||||
Test3();
|
||||
Test6();
|
||||
|
||||
Console.WriteLine("OK!");
|
||||
Console.ReadKey();
|
||||
|
@ -146,5 +146,20 @@ namespace Test
|
|||
XTrace.WriteLine(item.ToJson());
|
||||
}
|
||||
}
|
||||
|
||||
static async void Test6()
|
||||
{
|
||||
var client = new LocalStarClient();
|
||||
client.GetInfo();
|
||||
|
||||
try
|
||||
{
|
||||
await client.GetInfoAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
XTrace.Log.Error("星尘探测失败!{0}", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue