/// <summary> /// Sets the picture box's visibility in a thread-safe way. /// </summary> /// <param name="visible">Whether the picture box is visible</param> public void setPictureBoxVisibility(bool visible) { if (pictureBox.InvokeRequired) //wrong thread { pictureBoxVisibilityCallback d = new pictureBoxVisibilityCallback(setPictureBoxVisibility); pictureBox.Invoke(d, new object[] { visible }); } else //right thread { pictureBox.Visible = visible; } }
/// <summary> /// Sets the picture box's visibility in a thread-safe way. /// </summary> /// <param name="visible">Whether the picture box is visible</param> public void setPictureBoxVisibility(bool visible) { if (pictureBox.InvokeRequired) //wrong thread { pictureBoxVisibilityCallback d = new pictureBoxVisibilityCallback(setPictureBoxVisibility); pictureBox.Invoke(d, new object[] { visible }); } else //right thread { pictureBox.Visible = visible; } }