c# - Does setting the image of a PictureBox to the same image force a redraw? -
i have background thread checks communication status of hardware device (a camera) , updates image on form accordingly green circle or red x.
public bool camerastatus; public mainform() { initializecomponent(); // add updatedisplay function dictionary periodically called updatemethods.add(new eventhandler(updatedisplay)); } public void updatedisplay() { if (camerastatus) imgcamerastatus.image = properties.resources.camera_good; else imgcamerastatus.image = properties.resources.camera_bad; }
the updatedisplay
function gets called quite often, ever 50 ms or so. majority of time camerastatus
not change imgcamerastatus.image
keeps being set same value.
the image not flicker , wondering if image gets redrawn window each time or not, since source not change. not sure how lower-level painting function calls in winforms paint cycle.
looking @ the source code, setting image
property calls private method called installnewimage
. method call invalidate
schedule redraw of picturebox
in message queue.
Comments
Post a Comment