• asp.net开启多线程异步处理


     protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    try
                    {
                        Thread categoryThread = new Thread(new ThreadStart(BindCategory));
                        Thread newsThread = new Thread(new ThreadStart(BindNews));
    
    
                        categoryThread.Start();
                        newsThread.Start();
    
    
                        categoryThread.Join();
                        newsThread.Join();
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex);
                    }
                }
            }
      void BindCategory()
            {
    
    
                SqlConnection conn = ReturnSqlconn();
                SqlCommand comm = new SqlCommand("select * from  [dbo].[Channel_List]", conn);
                conn.Open();
                SqlDataReader sdr = comm.ExecuteReader();
    
    
                GridView1.DataSource = sdr;
                GridView1.DataBind();
            }
            void BindNews()
            {
                SqlConnection conn = ReturnSqlconn();
                SqlCommand comm = new SqlCommand("select * from  [dbo].[Channel_Type]", conn);
                conn.Open();
                SqlDataReader sdr = comm.ExecuteReader();
    
    
                GridView2.DataSource = sdr;
                GridView2.DataBind();
    
    
            }
     public SqlConnection ReturnSqlconn()
            { 
               string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
               SqlConnection cn = new SqlConnection(connectionString);
               return cn;
            }
  • 相关阅读:
    MongoDB ObjectId
    MongoDB固定集合
    MongoDB 正则表达式
    MongoDB Map Reduce
    MongoDB操作
    VIM跳到指定行
    linux之echo命令
    rpm and yum commands
    CentOS 7 下的软件安装建议
    apt系统中sources.list文件的解析
  • 原文地址:https://www.cnblogs.com/gsh0921/p/9329327.html
Copyright © 2020-2023  润新知