#ifndef Unit2H#define Unit2H//---------------------------------------------------------------------------#include //---------------------------------------------------------------------------class TThreadExParams{public: bool Cl_Stop; int Cl_B;}; class TRandomThread : public TThread{private:protected: void __fastcall Execute();public: __fastcall TRandomThread(bool CreateSuspended); AnsiString A; bool Stop; char ThreadPar1; int ThreadResult; int ThreadResultSum; int B; TThreadExParams *ThreadExParams;};//---------------------------------------------------------------------------#define MS_VC_EXCEPTION 0x406d1388typedef struct tagTHREADNAME_INFO{ DWORD dwType; // must be 0x1000 LPCSTR szName; // pointer to name (in same addr space) DWORD dwThreadID; // thread ID (-1 caller thread) DWORD dwFlags; // reserved for future use, most be zero} THREADNAME_INFO;void SetThreadName(DWORD dwThreadID, LPCTSTR szThreadName){ THREADNAME_INFO info; info.dwType = 0x1000; info.szName = szThreadName; info.dwThreadID = dwThreadID; info.dwFlags = 0; __try { RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(DWORD), (DWORD *)&info); } __except (EXCEPTION_CONTINUE_EXECUTION) { }}//---------------------------------------------------------------------------#endif
ThreadResultSum = ...;
.....class TThreadExParams{public: bool Cl_Stop; int Cl_B;}; class TRandomThread : public TThread{private:protected: void __fastcall Execute();public: __fastcall TRandomThread(bool CreateSuspended); AnsiString A; bool Stop; char ThreadPar1; int ThreadResult; int ThreadResultSum; int B;....
...int Form1ResultSum;... Form1ResultSum = Thread->ThreadResultSum;
void __fastcall TRandomThread::vzl(){Form1->Edit1->Text = "2";} ..... while(!Terminated){ Synchronize(vzl);}
while(!Terminated) { pcap_loop(adhandle, 0, packet_handler, NULL); Sleep(1); }
void __fastcall TRandomThread::Execute(){..... while(!Terminated ) { CntPack++; PostMessage(Form1->Handle,WM_USER+1,1,CntPack); }....
void __fastcall TRandomThread::Execute(){..... pcap_loop(adhandle, 0, packet_handler, NULL);
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data){...CntPack++;