protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
     _logger.LogInformation("后台控制台服务启动");
     Console.Title = $"白屏自动化,服务器: {authority},工作号:{account}";
     while (!stoppingToken.IsCancellationRequested)
     {
         await Task.Delay(1000 * 2, stoppingToken);
         clyg_sgui_cluster_node node = dal.SelectclusterByauthority(authority);
         if (node == null) 
         {
             node = new clyg_sgui_cluster_node() 
             {
                 account= account,
                 authority= authority,
                 expired=false,
                 locker=string.Empty,
                 timeout=0,
                 online=true,
                 version= Guid.NewGuid().ToString(),
                 lastcall = DateTimeOffset.Now.ToUnixTimeMilliseconds()
             };
             //添加进去  这种情况是第一次部署新的服务器会出现
             dal.Insertcluster(node);
         }
         try
         {
             Window window = null;
             Process Process = null;
             Application app = null;
             //查状态  

             var SguiProcess = Process.GetProcessesByName("共翔天易");
             if (SguiProcess.Length == 0) { Console.WriteLine($"程序未启动或异常关闭，请及时查看!"); isUpdateStart(node.online ? 1 : 0, 0); continue; }

             Process = SguiProcess.First();
             app = FlaUI.Core.Application.Attach(Process.Id);
             using (var automation = new UIA3Automation()) 
             {
                 Thread.Sleep(500);
                 window = app.GetMainWindow(automation);
                 Thread.Sleep(500);

                 var loginBtn = window.FindFirstDescendant(cf => cf.ByName("登录"));
                 if (loginBtn != null) { SMSHelper.DingSendMessage(dingerrorkey, "通知", $"白屏账号{account}已经失效，请及时查看!!:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}!!!", new List<string>() { }, new List<string>(), false, dingerrortoken); isUpdateStart(node.online ? 1 : 0, 0); continue; }

                 //查看定编按钮是否可用
                 var createPnrBtn = window.FindFirstDescendant(cf => cf.ByName("新建PNR"));
                 if (createPnrBtn == null) { SMSHelper.DingSendMessage(dingerrorkey, "通知", $"白屏账号{account}没有检测到新建pnr的按钮,请及时查看问题!!:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}!!!", new List<string>() { }, new List<string>(), false, dingerrortoken); Console.WriteLine("没有检测到新建pnr的按钮,请及时查看问题!"); isUpdateStart(node.online ? 1 : 0, 0); continue; }

                 //检测是否有弹窗(登录超时)未登录或登录超时
                 var IsLogin = window.FindFirstDescendant(cf => cf.ByName("未登录或登录超时"));
                 if (IsLogin != null) { SMSHelper.DingSendMessage(dingerrorkey, "通知", $"白屏账号{account}未登录或登录超时,请及时查看!!:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}!!!", new List<string>() { }, new List<string>(), false, dingerrortoken); Console.WriteLine("未登录或登录超时,请及时查看!"); isUpdateStart(node.online ? 1 : 0, 0); continue; }
             } ;

             //检查通道号是否更换 这种情况是服务器上更换通道号 或者 服务器白屏登录更换账号 会导致这种问题
             if (node.account != account) 
             {
                 dal.Updateclusteraccount(authority,account);
             }

             //正常状态
             isUpdateStart(node.online ? 1 : 0, 1);
         }
         catch (Exception ex) 
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
我该如何优化我的程序，减少内容的异常占用，我是用的是FlaUI.UIA3库3.2版本