后台线程连接数据库,照样界面假死?
private void btn_connect_Click(object sender, EventArgs e){ Thread th = new Thread(new ThreadStart(ConnectionTest)); th.IsBackground = true; th.Start();}void ConnectionTest(){ try { SqlConnection conn = new SqlConnection(connstr); conn.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }