Ejemplo n.º 1
0
        public static void EndPagding(IAsyncResult result)
        {
            ReconstructPaging item = result.AsyncState as ReconstructPaging;
            int rowCount           = 0;

            try
            {
                item.Result   = item.Method.EndInvoke(out rowCount, result);
                item.rowCount = rowCount;
            }
            catch (Exception ex)
            {
                item.Exception = ex;
            }
            finally
            {
                item.Event.Set();
            }
        }
Ejemplo n.º 2
0
        public static DbDataReader BeginPaging(this DbOperator dbOperator, string sql, int pageIndex, int pageSize, out int rowCount)
        {
            if (string.IsNullOrEmpty(sql))
            {
                throw new ArgumentNullException("sql");
            }
            m_Paging          paging = new m_Paging(Pagings);
            ReconstructPaging item   = new ReconstructPaging()
            {
                Event = new ManualResetEvent(false), Method = paging
            };
            IAsyncResult result = paging.BeginInvoke(dbOperator, sql, pageIndex, pageSize, out rowCount, new AsyncCallback(EndPagding), item);

            item.Event.WaitOne();
            if (item.Exception != null)
            {
                throw item.Exception;
            }
            rowCount = item.rowCount;
            return((DbDataReader)item.Result);
        }