Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ControlHelper.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Windows.Forms;
5 
6 namespace SiliconStudio.LauncherApp
7 {
8  public static class ControlHelper
9  {
10  public static void InvokeSafe<T>(this T control, Action action) where T : Control
11  {
12  // InvokeRequired required compares the thread ID of the
13  // calling thread to the thread ID of the creating thread.
14  // If these threads are different, it returns true.
15  if (control.InvokeRequired)
16  {
17  control.Invoke((MethodInvoker)delegate () { action(); });
18  }
19  else
20  {
21  action();
22  }
23  }
24  }
25 }