高分求解 ,关于线程,代理 ,弹出一form,终止数据库的查询。
//查询存储过程。
public SqlCommand GetAverValueProData()
{
SqlConnection conn = new SqlConnection();
// thread2 = Thread.CurrentThread;
conn.ConnectionString = sqlconn.sConn;
fnID= GetfnValue( "Select AGWSDb.dbo.my_fn_GetNewUnderCtrlProcID(Default) ");
//thread1 = new Thread(new ThreadStart());
.Open();
scmd.Connection = conn;
scmd.CommandTimeout = 30000;
scmd.CommandText = "my_proc_Rpt_Stat_RIData ";
scmd.CommandType = CommandType.StoredProcedure;
scmd.Parameters.Clear();
scmd.Parameters.Add(new SqlParameter( "@dtBeg ", SqlDbType.DateTime, 8));
scmd.Parameters.Add(new SqlParameter( "@dtEnd ", ype.DateTime, 8));
scmd.UpdatedRowSource = UpdateRowSource.Both;
scmd.Parameters[ "@dtBeg "].Value = this.dtPikStart.Value;
scmd.Parameters[ "@dtEnd "].Value = this.dtPikEnd.Value;
scmd.ExecuteNonQuery();
return scmd;
}
//主对话框中显示数据
thread1 = Thread.CurrentThread;
frm = new Form1(this);
frm.Show();
threadday = new Thread(new ThreadStart(SearchThread));
threadday.Start();
///////关键是下边的。如果没有下便的。是可以显示的。
{
SqlDataAdapter da = new SqlDataAdapter(controlAver .GetAverValueProData ());
ds = new DataSet();
da.Fill(ds, "my_proc_Rpt_Stat_RIData ");
this.dataGridView1.DataSource =ds.Tables [0];
}
////////////////////////////////////运行线程
private delegate void ChangeCallBack();
bool m_bSearchThread = true;
public void SearchThread()
{
m_bSearchThread = true;
if (m_bSearchThread)
ChangeCall();
}
private void ChangeCall()
{
if (this.InvokeRequired)
{
ChangeCallBack callback = new ChangeCallBack(ChangeCall);
this.Invoke(callback, new object[] { });