예제 #1
0
        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();
            }
        }
예제 #2
0
        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);
        }