private void Dispose(bool disposing) { if (!disposing) { return; } if (m_fontCache != null) { m_fontCache.Dispose(); m_fontCache = null; } if (m_gdiWriter != null) { m_gdiWriter.Dispose(); m_gdiWriter = null; } if (SharedImages == null) { return; } foreach (Image value in SharedImages.Values) { value.Dispose(); } SharedImages = null; }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_fontCache != null) { _fontCache.Dispose(); _fontCache = null; } } base.Dispose(disposing); }
private void DisposeGraphics() { if (m_bitsGraphics != null) { m_bitsGraphics.Dispose(); m_bitsGraphics = null; } if (m_hdcBits != null) { m_hdcBits.Dispose(); m_hdcBits = null; } if (m_fontCache != null) { m_fontCache.Dispose(); m_fontCache = null; } }
internal void DisposeGraphics() { m_textBoxDuplicates = null; m_itemPaddingsStyle = null; m_itemPropsStart = null; m_sharedImages = null; m_autosizeSharedImages = null; if (m_propertyCache != null) { m_propertyCacheReader = null; m_propertyCacheWriter = null; m_propertyCache.Close(); m_propertyCache.Dispose(); } if (m_bitsGraphics != null) { m_bitsGraphics.Dispose(); m_bitsGraphics = null; } if (m_hdcBits != null) { m_hdcBits.Dispose(); m_hdcBits = null; } if (m_scalabilityCache != null) { m_totalScaleTimeMs += m_scalabilityCache.ScalabilityDurationMs; m_peakMemoryUsageKB = Math.Max(m_peakMemoryUsageKB, m_scalabilityCache.PeakMemoryUsageKBytes); m_scalabilityCache.Dispose(); m_scalabilityCache = null; } if (m_fontCache != null) { m_fontCache.Dispose(); m_fontCache = null; } }
public void StressTest() { Font[] fonts = new Font[10]; for (int i = 0; i < 10; i++) { fonts[i] = new Font("Arial", i + 6); } FontCache cache = new FontCache(softLimit: 4, hardLimit: 8); Random random = new Random(); try { for (int i = 0; i < 10_000; i++) { Thread.Sleep(random.Next(5)); Task.Run(() => { using var hfont = cache.GetHFONT( fonts[random.Next(10)], (Gdi32.QUALITY)random.Next(7)); Assert.False(hfont.HFONT.IsNull); Thread.Sleep(random.Next(10)); }); } } finally { cache.Dispose(); for (int i = 0; i < 10; i++) { fonts[i]?.Dispose(); } } }
public void Dispose() { _fontCache.Dispose(); }
public virtual void Dispose() { m_fontCache.Dispose(); GC.SuppressFinalize(this); }