Hi, I'm sorry this yahoo Yahoo!Mail has marked your answer as junk and i realized it today by chance. Although I don't quite understand why, you seem to be right; I tried it and it worked. Thank you very much. Best regards. Muzaffer Peynirci
----- Original Message ---- From: Dimitry Timokhov <[EMAIL PROTECTED]> To: ICS support mailing <twsocket@elists.org> Sent: Monday, June 23, 2008 4:15:50 PM Subject: Re: [twsocket] THttpCli Problem in Multi Thread Application Hi. You shoul create THttpCli in context of your thread. Therefore you MUST call THttpCli in Execute method. Regards, Dimitry Timokhov 2008/6/23, muzaffer peynirci <[EMAIL PROTECTED]>: > 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 > -- Best regards, Dimitry Timokhov -- 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 -- 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