コード例 #1
0
        public static void EndExecuteReader(IAsyncResult result)
        {
            ReconstructReader item = result.AsyncState as ReconstructReader;

            try
            {
                item.Result = item.Method.EndInvoke(result);
            }
            catch (Exception ex)
            {
                item.Exception = ex;
            }
            finally
            {
                item.Event.Set();
            }
        }
コード例 #2
0
        public static DbDataReader BeginExecuteReader(this DbOperator dbOperator, string sql)
        {
            if (string.IsNullOrEmpty(sql))
            {
                throw new ArgumentNullException("sql");
            }
            m_Reader          readers = new m_Reader(Readers);
            ReconstructReader item    = new ReconstructReader()
            {
                Event = new ManualResetEvent(false), Method = readers
            };
            IAsyncResult result = readers.BeginInvoke(dbOperator, sql, new AsyncCallback(EndExecuteReader), item);

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