protected voidPage_Load (Objectsender, EventArgs e) { if(!IsPostBack) { Try{Thread Categorythread=NewThread (NewThreadStart (bindcategory)); Thread Newsthread=NewThread (NewThreadStart (bindnews)); Categorythread.start (); Newsthread.start (); Categorythread.join (); Newsthread.join (); } Catch(Exception ex) {Response.Write (ex); } } }
voidbindcategory () {SqlConnection conn=Returnsqlconn (); SqlCommand Comm=NewSqlCommand ("select * FROM [dbo]. [Channel_list]", conn); Conn. Open (); SqlDataReader SDR=Comm. ExecuteReader (); Gridview1.datasource=SDR; Gridview1.databind (); } voidbindnews () {SqlConnection conn=Returnsqlconn (); SqlCommand Comm=NewSqlCommand ("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; New SqlConnection (connectionString); return cn; }
ASP. NET turns on multithreading asynchronous processing