Hi Everyone;
I have a very simple program which has a second  thread namely HttpCliThread. 
In HttpCliThread I just create a THttpCli object sleep 1 second and then delete 
it. The problem takes place when I close the form; the form doesn't close 
properly and it gives error (The debugging steps of HttpCliThread go as 
expected, however). If I use a single thread everything is ok. Can you please 
help me or give me an idea of what is going on? 

Here is an example application to demonstrate my problem; 
http://rapidshare.com/files/124450794/httpClientTest.7z.html 
Here are my codes;

// HttpCliThread.h
//---------------------------------------------------------------------------

#ifndef HttpCliThreadH
#define HttpCliThreadH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include "HttpProt.hpp"
#include "FormMain.h"
//---------------------------------------------------------------------------
class HttpCliThread : public TThread
{
private:
    THttpCli *httpcli;
protected:
    void __fastcall Execute();
public:
    __fastcall HttpCliThread(bool CreateSuspended);
};
//---------------------------------------------------------------------------
#endif



// HttpCliThread.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "HttpCliThread.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------

__fastcall HttpCliThread::HttpCliThread(bool CreateSuspended)
    : TThread(CreateSuspended)
{
    FreeOnTerminate = true;
    httpcli = new THttpCli(NULL);
}
//---------------------------------------------------------------------------
void __fastcall HttpCliThread::Execute()
{
    Sleep(1000);
    if(httpcli) {
        delete httpcli;
        httpcli = NULL;
    }
}
//---------------------------------------------------------------------------



// FormMain.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "FormMain.h"
#include "HttpCliThread.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
HttpCliThread *thHttpCli;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
    : TForm(Owner)
{
    thHttpCli = new HttpCliThread(true);
    if(!thHttpCli) Application->Terminate();
    else thHttpCli->Resume();
}
//---------------------------------------------------------------------------

Best Regards...

-Muzaffer-


      
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to