Former-commit-id: 4bf7a3e655456678c795534104b7d8f54d6e27bf
TangShanKaiPing
wanggang 6 years ago
parent 0d3978671a
commit c26a182578

@ -1,16 +1,18 @@
using System; using System;
using System.Runtime.CompilerServices;
namespace Infrastructure.Extensions namespace Infrastructure.Extensions
{ {
public static class ExceptionExtensions public static class ExceptionExtensions
{ {
public static void PrintStack(this Exception ex, string message = null) public static void PrintStack(this Exception ex, string message = null, [CallerMemberName] string memberName = "")
{ {
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")); Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
if (message != null) if (message != null)
{ {
Console.WriteLine(message); Console.WriteLine(message);
} }
Console.WriteLine(memberName);
Console.WriteLine(ex.Message); Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
ex.InnerException?.PrintStack(); ex.InnerException?.PrintStack();

@ -66,17 +66,21 @@ namespace IoT.Shared.DeviceServices.FBee
{ {
while (!_tokenSource.IsCancellationRequested) while (!_tokenSource.IsCancellationRequested)
{ {
try foreach (var item in this.Clients)
{ {
foreach (var item in this.Clients) try
{ {
Console.WriteLine($"check gateway:{item.Key}"); Console.WriteLine($"check gateway:{item.Key}");
this.X9d(item.Key); this.X9d(item.Key);
} }
} catch (Exception ex)
catch (Exception ex) {
{ ex.PrintStack();
ex.PrintStack(); if (!item.Value.Client.Connected)
{
this.Connect(item.Value);
}
}
} }
await Task.Delay(1000 * 60); await Task.Delay(1000 * 60);
} }

Loading…
Cancel
Save