Dispose() 공개 메소드

public Dispose ( ) : void
리턴 void
예제 #1
0
 public static bool EnsureMemoryAvailability(int expectedSizeMegaBytes)
 {
     if (expectedSizeMegaBytes < 0)
     {
         throw new ArgumentException("Param expectedSizeBytes should be positive", "expectedSizeMegaBytes");
     }
     bool available = true;
     MemoryFailPoint p = null;
     try
     {
          p = new MemoryFailPoint(expectedSizeMegaBytes);
     }
     catch(InsufficientMemoryException)
     {
         available = false;
     }
     finally
     {
         if(p != null)
         {
             try { p.Dispose(); }
             catch(Exception)
             {
                 // ignored
             }
         }
     }
     return available;
 }
예제 #2
0
        public virtual bool IsSpaceAvailable(int sizeInMb)
        {
            if (sizeInMb < 1)
                return true;

            bool isAvailable = true;

            MemoryFailPoint _memoryFailPoint = null;
            try
            {
                _memoryFailPoint = new MemoryFailPoint(sizeInMb);
            }
            catch (InsufficientMemoryException)
            {
                isAvailable = false;
            }
            catch (NotImplementedException)
            {
                _logger.Warn("MemoryFailPoint is not implemented on this platform. The MemoryManager.IsSpaceAvailable() will just return true.");
            }
            finally
            {
                if (_memoryFailPoint != null)
                    _memoryFailPoint.Dispose();
            }

            return isAvailable;
        }
예제 #3
0
        public static void MemoryFailPointTestNoThrow()
        {
            MemoryFailPoint memFailPoint = null;

            memFailPoint = new MemoryFailPoint(1);
            memFailPoint.Dispose();
            memFailPoint = new MemoryFailPoint(2);
            memFailPoint.Dispose();
        }