> Hi, please share a minimal reproducible code sample.
It may take me a while to do that...
Meanwhile, 2 further things:
(1) Calling Flush() on one of my RenderTargets (during Print processing) somehow stopped all subsequent screen paints working. I have no idea why. But that was definitely the cause. If I commented out that line (or skipped past in the debugger), screen painting continued to work fine. If I left it in, all screen paints stopped working immediately. For the time being, I have stopped calling 'Flush' altogether on any RenderTargets.
(2) I realised that during Print processing, I actually can easily access an ID3D11DeviceContext, because I call D3D11CreateDeviceAndSwapChain which will return one if asked to do so. I tried storing a pointer to one of these, and calling 'ClearState' and 'Flush' on it before generating each new page in the Print process. It may have worked. It's hard to tell because I still got memory errors (see next para). But I commented it all out just to be safe when I had the problem with Flush being called on a RenderTarget (even though the ID3D11DeviceContext calls were not directly implicated).
The thing is, that even if the above calls to ClearState and Flush work, as far as I can see they only at best result in clearing cached resources associated with that particular ID3D11DeviceContext - i.e. resources that I have used exclusively during Print processing itself. But most of the problem is clearing all the cached resources that I use for screen painting, which I want to do right at the start of Print processing. And although I can free the relevant bitmaps (ID2D1Bitmap), I can't get Direct2D (or Direct3D) to synchronously free up the associated resources, because for screen painting, I only have a ID2D1RenderTarget (or a ID2D1DeviceContext) and can't find any way of getting hold of its associated ID3D11DeviceContext (although I assume there must be one somewhere?). Can you suggest any way that I can do that? - i.e. get hold of the ID3D11DeviceContext that is associated with the screen paints and their ID2D1RenderTarget ? I have done a lot of searching and failed to find a way of doing that.
For interest, my application is an MFC application and it just uses DirectWrite and Direct2D most of the time. I get a CDCRenderTarget passed to me from the MFC (via a message function that uses registered message AFX_WM_DRAW2D), and get the render target from that.
P.S. I just tried getting a ID2D1Device from the ID2D1DeviceContext passed to my app by the MFC, and calling "ID2D1Device::ClearResources" on that. It doesn't throw any errors but it also makes no significant difference.