mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
26 lines
640 B
C#
26 lines
640 B
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace CefSharp.WinForms.Example.Controls
|
|
{
|
|
public static class ControlExtensions
|
|
{
|
|
/// <summary>
|
|
/// Executes the Action asynchronously on the UI thread, does not block execution on the calling thread.
|
|
/// </summary>
|
|
/// <param name="control">the control for which the update is required</param>
|
|
/// <param name="action">action to be performed on the control</param>
|
|
public static void InvokeOnUiThreadIfRequired(this Control control, Action action)
|
|
{
|
|
if (control.InvokeRequired)
|
|
{
|
|
control.BeginInvoke(action);
|
|
}
|
|
else
|
|
{
|
|
action.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|