meen08 0 Newbie Poster

hello, I'm using builder c++ for a sniffer application.

I have a TThread object in a file called unit4 which show the packets in a TreeView.

__fastcall ThreadPackets::ThreadPackets(pcap_t* adhandle)
            : TThread(false), adhandle_(adhandle)
        {
            FreeOnTerminate = true; 
        }

void __fastcall ThreadPackets::Execute()
{
    while (!Terminated)
    {
        ....do something...
    }
}

I have added a button4 in main form (called Form1) asociated to unit1, when I click this button4 I want that my TThread object stopped.

so, in a file called unit3 I call this TThread object:

ThreadPackets *miThread = new ThreadPackets(adhandle); 

if (Form1->Button4->OnClick)
     {
      miThread->Terminate();
     }

but, when I click the button4 doesn't stop the application.

how can I do that?


thanks in advanced

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.