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;
}
}
}
2/3 首页 上一页 1 2 3 下一页 尾页 |