public static void SetMaxTS(this ProgressBar x, Int32 s) { if (x.InvokeRequired) { x.Invoke(new EventHandler(delegate(object o, EventArgs a) { x.SetMaxTS(s); })); } else { x.Maximum = s; } }