1

The Direct2D render loop is run on its own thread for aesthetic reasons. This enables smooth and instantaneous animations, regardless of window resize or other message pump blocks on the main thread. This render thread stays blocked most of the time (using Monitor.Wait) unless the scene is invalidated by mouse hovers, scrolling, window resizing, and so on.

I don't see a way to cancel the presentation once the drawing code calls BeginDraw on the render target. If the window is invalidated in certain ways, the scene is going to be thrown away and redrawn anyway. What can I do to get back to a clean slate, ready for the next BeginDraw, without finishing and presenting the scene? Can I cause a render error to interrupt the drawing thread that would skip the presentation?

jnm2
  • 7,960
  • 5
  • 61
  • 99
  • Does the rendering of one frame take so long that you need to bother? If so, you probably have a different problem. – Roger Rowland Jul 01 '14 at 12:09
  • I'm trying to alleviate [this flicker problem](http://stackoverflow.com/questions/1382915/how-to-fix-the-wpf-form-resize-controls-lagging-behind-and-black-background), for instance. Even with a simple clear it lags. I want to play with my options. Being forced to present the scene before resizing the render target is inefficient. – jnm2 Jul 01 '14 at 12:16

1 Answers1

0

Yeah, try and cause an error. For instance renderTarget->PushAxisAlignedClip() then renderTarget->EndDraw() without popping the clip. This will cause D2DERR_PUSH_POP_UNBALANCED (0x88990016). Then you'd have to Flush() the target to reset the error state.

vt.
  • 1,325
  • 12
  • 27