Multiprocotol Terminalprogram (BAT)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MultiTerm/Common/Helpers/ContextHelpers.cs

21 lines
591 B

namespace Common.Helpers;
public static class ContextHelpers
{
/// <summary>
/// Invokes context if necessary and runs action. If Threads are synchronized, runs action without switching context.
/// </summary>
/// <param name="context">context to run action on</param>
/// <param name="action">action to run</param>
public static void InvokeIfNecessary(IContext context, Action action)
{
if (context.IsSynchronized == false)
{
context.Invoke(action);
}
else
{
action.Invoke();
}
}
}