/// <summary>
/// Safely set the <see cref="Control.Enabled" /> and <see cref="Control.Visible" /> of a control across threads.
/// </summary>
/// <param name="control"></param>
/// <param name="value"></param>
public static void Usable( this Control control, Boolean value ) {
if ( null == control ) {
return;
}
if ( control.InvokeRequired ) {
control.BeginInvoke( new Action( () => {
if ( control.IsDisposed ) {
return;
}
control.Visible = value;
control.Enabled = value;
control.Refresh();
} ) );
}
else {
control.Visible = value;
control.Enabled = value;
control.Refresh();
}
}
No comments:
Post a Comment