C++ Builder 參考手冊(cè) ? System::Classes ? TThread ? WaitFor
頭文件:#include <System.Classes.hpp>
命名空間:System::Classes
類:TThread
訪問權(quán)限:public:
函數(shù)原型:
unsigned __fastcall WaitFor(void);
WaitFor 是 System::Classes::TThread 的成員函數(shù),等待線程結(jié)束期吓。
參數(shù):
無榨乎。
返回值:
線程結(jié)束時(shí) ReturnValue 屬性的值饭豹。
例子:
class TTestThread : public System::Classes::TThread
{
private:
void __fastcall SetLabelValue(void)
{
Form1->Label1->Caption = StrToIntDef(Form1->Label1->Caption,0) + 1;
}
protected:
void __fastcall Execute(void)
{
while(!Terminated)
{
Synchronize(SetLabelValue);
Sleep(200);
}
}
};
TTestThread *lpTestThread = NULL;
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(!lpTestThread)
{
lpTestThread = new TTestThread;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(lpTestThread)
{
lpTestThread->Terminate();
lpTestThread->WaitFor();
delete lpTestThread;
lpTestThread = NULL;
}
}
相關(guān):
- System::Classes::TThread::ReturnValue
- System::Classes::TThread::Terminate
- System::Classes::TThread::Terminated
- System::Classes::TThread::TerminatedSet
- System::Classes::TThread::FreeOnTerminate
- System::Classes::TThread::Finished
- System::Classes::TThread::Started
- System::Classes::TThread::Execute
- System::Classes::TThread::WaitFor
- System::Classes::TThread
- System::TObject
- VCL 類繼承關(guān)系
C++ Builder 參考手冊(cè) ? System::Classes ? TThread ? WaitFor