//private: void ConnectTableAsync(IDataTable table) { var waitClue = new Waits.WaitClue(this); Action connect = () => { if (!table.IsConnected) { table.Connect(); } var fuzzyTable = table as IFuzzyDataTable; IDatumProvider dp = (fuzzyTable?.RowProvider) ?? table.DataProvider; dp.Connect(); lock (m_dpCache) m_dpCache[table.ID] = dp; }; Action onSuccess = () => { waitClue.LeaveWaitMode(); SetInfo(table); }; Action <Task> onError = t => { waitClue.LeaveWaitMode(); Exception ex = t.Exception.InnerException; MessageBox.Show(ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error); m_lvTables.SelectedItems.Clear(); }; waitClue.EnterWaitMode(); var connecting = new Task(connect, TaskCreationOptions.LongRunning); connecting.OnError(onError); connecting.OnSuccess(onSuccess); connecting.Start(); }