static void CallbackMethod(IAsyncResult result) { AsyncResult ar = (AsyncResult)result; ExecuteFuncDelegate caller = (ExecuteFuncDelegate)ar.AsyncDelegate; CELBase task = (CELBase)ar.AsyncState; if (task.target != null) { if (task.target is Control) { CELAsyncResultReceiverTaskMethod method = new CELAsyncResultReceiverTaskMethod(task.target.TaskFinished); Control ctrl = task.target as Control; while (!ctrl.IsHandleCreated) { System.Threading.Thread.Sleep(100); } ctrl.Invoke(method, task); } else { task.target.TaskFinished(task); } } }
/// <summary> /// needs to be executed on thread of Control /// </summary> /// <param name="task"></param> public void FlushResultsToControlSync(CELBase task) { /*listControl.BeginUpdate(); * * foreach (Results res in ResultsList) * { * listControl.Items.Add(res); * } * ResultsList.Clear(); * listControl.EndUpdate();*/ }
/// <summary> /// needs to be executed on thread of Control /// </summary> /// <param name="task"></param> public void ClearControlListSync(CELBase task) { //listControl.Items.Clear(); }