c++builder XE6 线程
class TSleepFunc : public TCppInterfacedObject<TProc> { public: TSleepFunc(TForm28* Form) : FForm(Form) { } virtual void __fastcall Invoke(void) { for (FForm->ClientDataSet1->First(); !FForm->ClientDataSet1->Eof; FForm->ClientDataSet1->Next()) { FForm->ClientDataSet1->Edit(); FForm->ClientDataSet1->FieldByName("Stat")->Value = FForm->ClientDataSet1->RecNo; FForm->ClientDataSet1->Post(); } TThread::Synchronize(TThread::CurrentThread, UpdateCaption); } void __fastcall UpdateCaption(void) { FForm->Caption = "OK"; } private: TForm28* FForm; }; // --------------------------------------------------------------------------- void __fastcall TForm28::Button1Click(TObject *Sender) { ClientDataSet1->Close(); ADOQuery1->Close(); ADOQuery1->SQL->Text = "select * from brda"; ADOQuery1->Open(); ClientDataSet1->Open(); TThread::CreateAnonymousThread(new TSleepFunc(this))->Start(); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。