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(); }
时间: 2024-11-09 02:52:54