Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upComException 0x80004005 thrown by CanvasVirtualControl Invalidate() if there is an active CanvasDrawingSession #612
Comments
|
I don't believe it's supported to Invalidate while inside a drawing operation. Can you synchronize to avoid doing that? |
|
Unfortunately, no. I noticed intermittent errors and tracked it down to the outer container issuing redraw requests as other controls moved/resized or whatever. I found I could reliably recreate the problem if Invalidate fires while the drawing session is open, hence the code above. Since I'm deliberately not blocking the UI thread, requests can trickle through and I don't know of a way to intercept invalidate requests. I can't overload the CanvasVirtualControl's Invalidate because it is sealed. I'll give it some thought. Perhaps I can redesign where the canvas sits to minimize the possibility the app asks for a redraw (or find some way to intercept the request). |
|
We're not planning on making any changes to Win2D to alter the behavior of this scenario, so you will have to synchronize this in app code. Suggest keeping track of when you are in the middle of a drawing operation, and deferring any incoming invalidate requests until the draw has completed. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

I am using a background thread to update a CanvasVirtualControl because the redraw time has started to affect the UI thread (there are a lot of complex objects and text).
I am using option 1 from the CreateDrawingSession remarks:
When the update is lightweight, everything seems to be fine. Once the update starts to consume time, I start getting ComException 0x80004005. I get the exception consistently by calling Invalidate while the drawing session is open.
Below are the page SizeChanged method, the RegionsInvalidated method (which enqueues the invalid rectangles and verifies the background task is running) and the actual redraw method.