Since most Windows apps are UI driven, and Windows UI is driven by fetching messages from the message queue, one common way to define when an application is "idle" is when it has no messages in its message queue.
There are always messages flying around in a Windows app (user generated and system generated), but you will see frequent short idle periods in a typical app. When the mouse moves over a window in your app, your idle periods will drop to near zero until the mouse stops moving because mouse activity generates a lot of message activity.
So, in your Windows app s message loop, if you are currently using GetMessage you will need to change your loop to use PeekMessage instead. GetMessage blocks when the message queue is empty until a message arrives. PeekMessage returns true if there is a message in the queue or false if there is none. With flags you can make PeekMessage get the message in the same call.
When PeekMessage returns false, you can divert execution to your "idle" task instead of waiting for the next message.
In WinForms applications, use the Application.Idle event
Don t do too much in your idle code though, or your UI will feel sluggish because messages aren t being processed quickly. Overuse of the idle cycle will also make your CPU run hot and drain your laptop battery.