WPF Render Thread Failures

A common problem developers face with WPF applications is how to deal with exceptions related to render thread failures. You might get reports from users indicating their application throws an exception like one of the following. System.Runtime.InteropServices.COMException: UCEERR_RENDERTHREADFAILURE (Exception from HRESULT: 0x88980406)   at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()   at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)   at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget)   at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)  …

6

Using a Custom AutomationPeer in Cases of UIA Related Performance Degradation

Summary The Microsoft User Interface Automation (UIA) framework is great for helping automate testing and provide accessibility services for applications generally, but there are some cases where it may be disadvantageous for a client with very deeply nested UI components, since UIA requests can become taxing under those circumstances, degrading performance particularly.  This may even…


Using Theme APIs to draw the border of a control

In this article, we will take a look at using the Theme APIs to draw the border of a control using the current visual style. Each window class is responsible for defining its appearance, which includes the client and non-client portions of the window. A window’s border is typically part of its non-client area. Windows…


Printing from a Windows Service

It is often desirable to print a document to a printer from your Windows service.  While calling the Windows Win32 GDI APIs to send a document to the printer is supported, there are some important considerations to take into account, such as which user account the service is running under, and whether that user has…

3

Debugging a GDI Resource Leak

One of the most common graphics-related problems we see is a “GDI leak” (or, simply the usage of too many GDI objects), which will eventually cause rendering problems, errors, and/or performance problems. Some things need to be defined and explained before I talk about how we debug these problems.    –Definitions– GDI Objects are resources…


Using Direct2D from a service in C#

It is often desirable to create graphical images on disk from a service context.  For example, some server applications need to render images and send back the generated bitmaps to users connected through web clients. One example would be an ASP.NET web application which needs to generate user profile pictures on the fly. We have…

3

Ways to capture the screen

Capturing the screen (or put another way, creating an in-memory copy of the image currently being displayed on the screen, for re-display, printing, or later saving) is a task with many different solutions.  I’ll try to enumerate the possibilities below.  This isn’t a perfect or complete list, but it covers the best supported ways, and lists some…