internal UseLevel GetUseLevel(long pressure, UseLevel previousUseLevel)
 {
     if (pressure > this.mediumToHigh)
     {
         return(UseLevel.High);
     }
     if (PressureTransitions.Between(pressure, this.highToMedium, this.mediumToHigh))
     {
         if (previousUseLevel == UseLevel.High)
         {
             return(UseLevel.High);
         }
         return(UseLevel.Medium);
     }
     else
     {
         if (PressureTransitions.Between(pressure, this.lowToMedium, this.highToMedium))
         {
             return(UseLevel.Medium);
         }
         if (PressureTransitions.Between(pressure, this.mediumToLow, this.lowToMedium) && (previousUseLevel == UseLevel.Medium || previousUseLevel == UseLevel.High))
         {
             return(UseLevel.Medium);
         }
         return(UseLevel.Low);
     }
 }
Exemple #2
0
 protected ResourceMeter(string resourceName, string resourceInstanceName, PressureTransitions pressureTransitions)
 {
     ArgumentValidator.ThrowIfNullOrEmpty("resourceName", resourceName);
     ArgumentValidator.ThrowIfNull("resourceInstanceName", resourceInstanceName);
     this.resourceIdentifier  = new ResourceIdentifier(resourceName, resourceInstanceName);
     this.pressureTransitions = pressureTransitions;
     this.resourceUse         = new ResourceUse(this.resourceIdentifier, UseLevel.Low, UseLevel.Low);
 }
 public PrivateBytesResourceMeter(PressureTransitions pressureTransitions, ulong totalPhysicalMemory) : base("PrivateBytes", string.Empty, pressureTransitions)
 {
     ArgumentValidator.ThrowIfInvalidValue <ulong>("totalPhysicalMemory", totalPhysicalMemory, (ulong memory) => memory > 0UL);
     this.totalPhysicalMemory = totalPhysicalMemory;
 }
 public UsedDiskSpaceResourceMeter(string directoryName, PressureTransitions pressureTransitions) : this("UsedDiskSpace", directoryName, pressureTransitions)
 {
 }
 protected UsedDiskSpaceResourceMeter(string resourceName, string directoryName, PressureTransitions pressureTransitions) : base(resourceName, directoryName, pressureTransitions)
 {
     ArgumentValidator.ThrowIfNullOrEmpty("directoryName", directoryName);
 }
Exemple #6
0
 public SystemMemoryResourceMeter(PressureTransitions pressureTransitions) : base("SystemMemory", string.Empty, pressureTransitions)
 {
 }