private static void ControlInvoke(Control ctrl, Action <AsyncTask> callback, AsyncTask task) { if (ctrl != null) { EventHandler Invoker = null; Invoker = (object sender, EventArgs e) => { ctrl.HandleCreated -= Invoker; callback(task); }; if (ctrl.IsHandleCreated) { ctrl.Invoke(new Action(() => { callback(task); })); } else { ctrl.HandleCreated += Invoker; } } }