public void DiscardDeviceResources() { _renderTarget?.Dispose(); _renderTarget = null; if (_memDC != IntPtr.Zero && _hBitmap != IntPtr.Zero && _hOldBitmap != IntPtr.Zero) { Gdi32.SelectObject(_memDC, _hOldBitmap); Gdi32.DeleteObject(_hBitmap); } if (_memDC != IntPtr.Zero) { Gdi32.DeleteDC(_memDC); } if (_screenDC != IntPtr.Zero) { User32.ReleaseDC(IntPtr.Zero, _screenDC); } _hOldBitmap = IntPtr.Zero; _hBitmap = IntPtr.Zero; _memDC = IntPtr.Zero; _screenDC = IntPtr.Zero; GC.Collect(); }
private void Dispose(bool disposing) { if (_disposed) { return; } _disposed = true; if (Handle == IntPtr.Zero) { return; } if (_renderTarget != null) { _renderTarget.Dispose(); _renderTarget = null; } _d2dFactory.Dispose(); _d2dFactory = null; if (_memDC != IntPtr.Zero) { Gdi32.DeleteDC(_memDC); } if (_screenDC != IntPtr.Zero) { User32.ReleaseDC(IntPtr.Zero, _screenDC); } _memDC = IntPtr.Zero; _screenDC = IntPtr.Zero; User32.DestroyWindow(Handle); Handle = IntPtr.Zero; gcHandle.Free(); }
private void DiscardDeviceResource() { _renderTarget?.Dispose(); _renderTarget = null; if (_memDC != IntPtr.Zero && _hBitmap != IntPtr.Zero && _hOldBitmap != IntPtr.Zero) { Gdi32.SelectObject(_memDC, _hOldBitmap); Gdi32.DeleteObject(_hBitmap); } _hOldBitmap = IntPtr.Zero; _hBitmap = IntPtr.Zero; GC.Collect(); }