Monitor.cs
1.0 KB
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
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScanCodeServer
{
public class Monitor
{
public static int ScanMemory = 0;
public static int ScanTimes = 0;
public static int MaxMenory=5000;
public static event EventHandler OverTimes;
static bool overtimes = false;
public static void Test() {
Task.Run(() =>
{
if (ScanMemory > MaxMenory)
FireOverTimes();
});
}
static void FireOverTimes() {
if (!overtimes)
{
Common.log.Info($"内存已超阈值:{ScanMemory}/{MaxMenory}mb");
overtimes = true;
OverTimes?.Invoke(null, EventArgs.Empty);
}
}
static public void FireExit(string msg)
{
Common.log.Info(msg);
overtimes = true;
OverTimes?.Invoke(null, EventArgs.Empty);
}
}
}