none
RenderTargetBitmap throws COM exception when created too fast: MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003)

    Question

  • I am trying to use RenderTargetBitmaps to cache parts of a control I am rendering.  If I start creating the bitmaps too fast, the constructor of RenderTargetBitmap throws the exception: MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003).

    I have tried to research this problem and one suggestion was to force GB, but that completely locks up the app for some time.

    Code:

    private void PopulateCache(Position pos) { DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext dc = drawingVisual.RenderOpen()) { // Many dc.DrawImage() }

    // throws MILERR_WIN32ERROR (Exception from HRESULT: 0x88980003) if called in rapid succesion var bmp = new RenderTargetBitmap(700, 700, 96, 96, PixelFormats.Pbgra32); bmp.Render(drawingVisual); bmp.Freeze(); m_Cache[pos] = bmp; }

    Does anyone know of a viable workaround for this?

    Sunday, April 17, 2016 2:42 AM

Answers

All replies