Asp.Net多线程用法1
2016-03-24 15:18
471 查看
Asp.Net多线程简单用法
一个web页面 default.aspx 里面有两个控件GridView1,GridView2,通过两个线程分别加载绑定数据。protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { Thread thead1 = new Thread(new ThreadStart(BindPeople));//定义线程 Thread thead2 = new Thread(new ThreadStart(BindNews)); thead1.Start(); //启动线程 thead2.Start(); thead1.Join(); //大概就是和UI线程同步的意思 thead2.Join(); } catch (Exception ex) { Response.Write(ex); } } } /// <summary> /// 绑定用户 /// </summary> private void BindPeople() { DataTable dt = DBHelper.GetDataTable("select * from people"); GridView1.DataSource = sdr; GridView1.DataBind(); } /// <summary> /// 绑定新闻 /// </summary> private void BindNews() { DataTable dt = DBHelper.GetDataTable("select * from news"); GridView2.DataSource = sdr; GridView2.DataBind(); }
相关文章推荐
- asp.net webform 中将前台显示出来的html标签解释为排版格式
- ASP.NET Core 1.0中的管道-中间件模式
- ASP.NET在底层类库中获取Session C#类中获取Session[原创]_实用技巧_脚本之家
- Raspberry 2 B 使用记录
- ASP.NET-文件上传代码
- ASP.NET-跨站伪造请求CSRF
- ASP.NET-缓存outputcache参数
- ASP.NET-本地化、全球化
- ASP.NET-使用事件监视诊断程序异常
- ASP.NET-缓存基本知识点
- ASP.NET-Razor语法03
- ASP.NET-ajax.BeginForm使用02
- ASP.NET-ajax.acionlink使用
- ASP.NET-表单验证-DataAnnotations
- ASP.NET-Router配置中MapRoute的参数
- ASP.NET-Razor常用方法
- ASP.NET-RedirectToAction只能使用get方法
- ASP.NET Core 行军记 -----第一步(艰辛的 MVC Hello World)
- C# asp.net mvc 配置多个route 参数
- ASP.NET在底层类库中获取Session C#类中获取Session 原创