using System; using System.Windows.Forms; namespace CefSharp.WinForms.Example.Controls { public static class ControlExtensions { /// /// Executes the Action asynchronously on the UI thread, does not block execution on the calling thread. /// /// the control for which the update is required /// action to be performed on the control public static void InvokeOnUiThreadIfRequired(this Control control, Action action) { if (control.InvokeRequired) { control.BeginInvoke(action); } else { action.Invoke(); } } } }