public static void RunOnUIThread(System.Windows.Forms.Control control, UIHelper.Action action) { if (UIHelper.obj == null) { if (control != null && control.InvokeRequired) { control.Invoke((Delegate)action); } else { if (action == null) { return; } action(); } } else { if (control == null || !control.InvokeRequired) { return; } object obj = UIHelper.obj((Delegate)action, new object[0]); } }
public static void RunCommandAsync( string cmd, UIHelper.Action continuation, Control control, string vmName) { System.Threading.Timer timer = new System.Threading.Timer((TimerCallback)(obj => { VmCmdHandler.RunCommand(cmd, vmName, "bgp"); if (continuation == null) { return; } UIHelper.RunOnUIThread(control, continuation); }), (object)null, 0, -1); }
private static void SendControllerEventInternal(string cmd, UIHelper.Action continuation) { Logger.Info("Sending controller event " + cmd); VmCmdHandler.RunCommandAsync(cmd, continuation, (Control)VMWindow.Instance, MultiInstanceStrings.VmName); }