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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -