public static void EndExecuteTable(IAsyncResult result) { ReconstructTables item = result.AsyncState as ReconstructTables; try { item.Result = item.Method.EndInvoke(result); } catch (Exception ex) { item.Exception = ex; } finally { item.Event.Set(); } }
public static DataTable BeginExecuteTable(this DbOperator dbOperator, string sql) { if (string.IsNullOrEmpty(sql)) { throw new ArgumentNullException("sql"); } t_DataTable paging = new t_DataTable(Tables); ReconstructTables item = new ReconstructTables() { Event = new ManualResetEvent(false), Method = paging }; IAsyncResult result = paging.BeginInvoke(dbOperator, sql, new AsyncCallback(EndExecuteTable), item); item.Event.WaitOne(); if (item.Exception != null) { throw item.Exception; } return((DataTable)item.Result); }