Пример #1
0
        public async Task GetMonitor()
        {
            while (true)
            {
                float cpuUsage = _statService.getCurrentCpuUsage();

                float memUsage = _statService.getUsageRAM();

                //System.Console.WriteLine($"CPU : {cpuUsage} RAM : {memUsage}");

                await Clients.Client(Context.ConnectionId).SendAsync("SendMonitorData", JsonSerializer.Serialize(
                                                                         new
                {
                    CPU = cpuUsage,
                    RAM = memUsage
                }));

                await Task.Delay(1000);
            }
        }