As a performance optimization the GDI performs batching. When you ask GDI to perform an operation it doesn't always execute it immediately. Instead, it stores it in a buffer and once that buffer gets full the batch gets flushed and the operations get sent to kernel mode for execution. This is what GDI does by default and there is usually no reason to change this mode of operation.
Occasionally you need control over how much batching GDI performs or when flushing occurs, either because you are rendering to an offscreen DC and need to read that information back from memory, or for debugging purposes.
There are 2 API calls you can use to control batching. To initiate a flush of the batched up operations you can call GdiFlush
. Once this API returns you are guaranteed that all GDI operations have run to completion. If you want to control the amount of batching performed you can use GdiSetBatchLimit
. To disable batching altogether simply call GdiSetBatchLimit(1)
.