首页 > 代码库 > c++builder XE6 线程

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 = http://www.mamicode.com/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();}

 

c++builder XE6 线程