protected virtual void OnLowMemory(LowMemoryEventArgs e)
{
LowMemory?.Invoke(this, e);
- double interval = new Random().Next(10 * 1000);
- if (interval <= 0)
- interval = 10 * 1000;
-
- sTimer = new System.Timers.Timer(interval);
- sTimer.Elapsed += OnTimedEvent;
- sTimer.AutoReset = false;
- sTimer.Enabled = true;
+ if (e.LowMemoryStatus == LowMemoryStatus.SoftWarning || e.LowMemoryStatus == LowMemoryStatus.HardWarning)
+ {
+ double interval = new Random().Next(10 * 1000);
+ if (interval <= 0)
+ interval = 10 * 1000;
+
+ sTimer = new System.Timers.Timer(interval);
+ sTimer.Elapsed += OnTimedEvent;
+ sTimer.AutoReset = false;
+ sTimer.Enabled = true;
+ }
}
private static void OnTimedEvent(Object source, ElapsedEventArgs e)