轮胎外观检测添加思谋语义分割模型检测工具
C3204
2026-03-30 06c627ec032b3f3876fd7db8a3ff0ff1a6614fa2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace LB_SmartVisionCommon
{
    public class NetworkMonitor
    {
        private System.Timers.Timer _timer;
 
        public event Action<bool> NetworkStatusChanged;
 
        public void StartMonitoring(int intervalSeconds = 30, string ip = "www.google.com")
        {
            _timer = new System.Timers.Timer(intervalSeconds * 1000);
            _timer.Elapsed += async (s, e) => await CheckNetworkAsync(ip);
            _timer.Start();
        }
 
        public void StopMonitoring()
        {
            _timer?.Stop();
            _timer?.Dispose();
        }
 
        private async Task CheckNetworkAsync(string ip = "www.google.com")
        {
            var isConnected = await NetworkTester.TestConnectionAsync(ip);
            NetworkStatusChanged?.Invoke(isConnected);
        }
    }
}