I have a WinForms app (C#, .NET 4.7) that processes a video frame-by-frame in a background thread. There is a PictureBox
control for preview which displays frames being processed in real-time.
This all works fine but I'd like to detect if the container form is visible on screen or occluded by other windows. Since previewing in the PictureBox
is a performance bottleneck, I'd like to skip frame preview if and only if the form is not visible to the user.
Determining if the form is in focus is simple but not enough.
Is there a way to determine this in managed or un-managed code?