private void EnsureDeviceContextIsValid() { if (_isDeviceContextValid) { return; } _isDeviceContextValid = true; _deviceContext.Dispose(); _deviceContext = DeviceContext.GetVirtualMonitor(); _lastConfiguration = null; }