用了线程,为什么主界面不响应??

tycooncool 2004-02-13 05:19:06
我有一个程序,用了线程来执行存储过程,主窗体用来显示不断执行滚动条
,但我遇到这样的情况,一执行存储过程,滚动条就停止了!要等执行完了
后滚动条才会动,不知道为什么?
void __fastcall TMythread::Execute()
{
Synchronize(ExecSQL);
}
void __fastcall TMythread::ExecSQL()
{

cnt->Query1->SQL->Clear(); //ADOQuery
cnt->Query1->SQL->Add(sql);
cnt->Query1->Active=1;

}
主窗体用Timer控件不停循环执行滚动,

void __fastcall TFframe::Timer2Timer(TObject *Sender)
{
CGauge1->MinValue = 0;
CGauge1->MaxValue =1000;
CGauge1->Progress = 0;
for ( int i=0; i<1000;i++)

{
CGauge1->AddProgress(1);
Application->ProcessMessages();
}


}
但一执行线程,滚动条就停止了!!界面就不响应了,错在哪里了???
void __fastcall TFframe::updateClick(TObject *Sender) //执行按钮
{
th1 = new TMythread(false);
Timer2->Enabled=true;
if (gb->Checked)
{

gbgx->Caption="正 在 扫 描。。。";
sql="declare @info varchar(200),@i int exec update_gb @info output,@i output select @info,@i"; //执行过程
gbgx->Caption="数据更新成功。。。";
}
}
...全文
74 36 打赏 收藏 转发到动态 举报
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧