免费邮箱 |加入收藏 | 会员中心 | 我要投稿 | RSS
您当前的位置:首页 > .NET专区 > ASP.NET应用

Ado.net快马加鞭

时间:2011-05-21 10:47:30  来源:站内  作者:潘春会

        SqlCommand MMCommand = new SqlCommand("select Title ,Content from MM,Table_2 where MM.ID=Table_2.Id", DBCon);//Table_2.Id其实是上面的Table_2地一列

        Table_1Command.CommandType = CommandType.Text;
        MMCommand.CommandType = CommandType.Text;

        SqlDataReader Table_1DataReader;
        SqlDataReader MMDataReader;

        IAsyncResult Table_1AsyncResult;
        IAsyncResult MMAsyncResult;

        System.Threading.WaitHandle[] WHandles = new System.Threading.WaitHandle[2];

        //封装等待对共享资源的独占访问的操作系统特定的对象。
        System.Threading.WaitHandle Table_1Whandle;
        System.Threading.WaitHandle MMWhandle;

        try
        {

            DBCon.Open();
            Table_1AsyncResult = Table_1Command.BeginExecuteReader();
            MMAsyncResult = MMCommand.BeginExecuteReader();

            Table_1Whandle = Table_1AsyncResult.AsyncWaitHandle;
            MMWhandle = MMAsyncResult.AsyncWaitHandle;

            WHandles[0] = Table_1Whandle;
            WHandles[1] = MMWhandle;

            System.Threading.WaitHandle.WaitAny(WHandles);

 

 

            for (int index = 0; index < 2; index++)
            {
                //--------返回完成执行等待句柄索引该数据在WHandles索引里面的某个
                int whindex = System.Threading.WaitHandle.WaitAny(WHandles);
                switch (whindex)
                {
                    //注意这里必须和上面装入WHandles集合的索引一样
                    case 0:
                        Table_1DataReader = Table_1Command.EndExecuteReader(Table_1AsyncResult);
                        GridView1.DataSource = Table_1DataReader;
                        GridView1.DataBind();
                        break;
                    case 1:

                        MMDataReader = MMCommand.EndExecuteReader(MMAsyncResult);
                        GridView2.DataSource = MMDataReader;
                        GridView2.DataBind();

                        break;

                }

            }

 

        }

来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
如何找出DHCP地址池里未使用的IP地址
如何找出DHCP地址池里
国内常用的DNS列表
国内常用的DNS列表
Linux邮件服务器软件比较
Linux邮件服务器软件比
学用纯CSS打造可折叠树状菜单
学用纯CSS打造可折叠树
相关文章
栏目更新
栏目热门