Re: [twsocket] Program to thread
>> Of course. Be sure to create it from the thread's Execute method. > > Just being curious : why does is have to be created in > the thread's execute procedure ? As you know, ICS component use hidden window to receive notification messages from winsock and to use internal messages. By Windows design, messages are processed in the context of the thread having created the window. So if you create a component in the main thread context, all his messages will be handled by the main thread. If you create a component from a thread Execute method, all messages will be processed in that thread context. Side note: A thread constructor is executed in the context of the calling thread (usually the main thread) that's why you should not create the ICS component in TTHread.Create but in TThread.Execute. ICS component has a ThreadDetach and a ThreadAttach procedure. They simply destroy and recreate the hidden window. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
Because the otherwise it would execute in the main thread context. Or you can use ThreadAttach which would be a waste of CPU cycles... Regards, SZ - Original Message - From: "Paul" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Monday, June 05, 2006 3:32 PM Subject: Re: [twsocket] Program to thread >>> - HttpCli.create(nil) >> Of course. Be sure to create it from the thread's Execute method. > > Just being curious : why does is have to be created in the thread's > execute > procedure ? > > > Paul > > > - Original Message - > From: "Francois PIETTE" <[EMAIL PROTECTED]> > To: "ICS support mailing" > Sent: Monday, June 05, 2006 11:03 AM > Subject: Re: [twsocket] Program to thread > > >>> What is the correct way to convert an existing program with 1 HttpCli in >>> async mode to a thread? >>> >>> - HttpCli.create(nil) >> >> Of course. Be sure to create it from the thread's Execute method. >> >>> - HttpCli.Multithreaded:= true >> >> OK. >> >>> - place a message pump in the thread's execute procedure. >> >> OK. >> >>> - create a hidden window to post message to >> >> Only if you need one for your own use. >> >>> Something else to do ? >> >> Start the event chain just before entering the message pump. >> >> >> -- >> Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html >> -- >> [EMAIL PROTECTED] >> http://www.overbyte.be >> >> >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://www.elists.org/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be >> >> > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
>> - HttpCli.create(nil) > Of course. Be sure to create it from the thread's Execute method. Just being curious : why does is have to be created in the thread's execute procedure ? Paul - Original Message - From: "Francois PIETTE" <[EMAIL PROTECTED]> To: "ICS support mailing" Sent: Monday, June 05, 2006 11:03 AM Subject: Re: [twsocket] Program to thread >> What is the correct way to convert an existing program with 1 HttpCli in >> async mode to a thread? >> >> - HttpCli.create(nil) > > Of course. Be sure to create it from the thread's Execute method. > >> - HttpCli.Multithreaded:= true > > OK. > >> - place a message pump in the thread's execute procedure. > > OK. > >> - create a hidden window to post message to > > Only if you need one for your own use. > >> Something else to do ? > > Start the event chain just before entering the message pump. > > > -- > Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html > -- > [EMAIL PROTECTED] > http://www.overbyte.be > > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be > > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
Arno Garrels wrote: > Paul wrote: >> Hi Arno >> >>> not required, you can also use PostThreadMessage(). >> Can I trap my own messages within the message pump here ? > > No problem i.e.: Also make sure thread's message queue is initialized before PostThreadMessage(). First line in Execute could be PeekMessage() with PM_NOREMOVE to initialize the queue. --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
Paul wrote: > Hi Arno > >> not required, you can also use PostThreadMessage(). > Can I trap my own messages within the message pump here ? No problem i.e.: while GetMessage(Msg, 0, 0, 0) do begin if Msg.message = WM_USER + 1 then TWSocket(Msg.WParam).ThreadAttach else if Msg.message = WM_USER + 2 then begin TWSocket(Msg.WParam).ThreadDetach; Postmessage(Form1.Handle, WM_USER + 3, Msg.WParam, 0); end else begin TranslateMessage(Msg); DispatchMessage(Msg); end; end; > >> Think fully event-driven ;-) > It' the only I can ;-) > > > Paul -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
Hi Arno > not required, you can also use PostThreadMessage(). Can I trap my own messages within the message pump here ? > Think fully event-driven ;-) It' the only I can ;-) Paul -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
Paul wrote: > What is the correct way to convert an existing program with 1 HttpCli > in async mode to a thread? > > - HttpCli.create(nil) Either create it in thread's Execute procedure or create it in another thread, call ThreadDetach, and in thread's Execute call ThreadAttach. > - HttpCli.Multithreaded:= true > - place a message pump in the thread's execute procedure. > - create a hidden window to post message to not required, you can also use PostThreadMessage(). > Something else to do ? Think fully event-driven ;-) --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html > > Paul -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
> What is the correct way to convert an existing program with 1 HttpCli in > async mode to a thread? > > - HttpCli.create(nil) Of course. Be sure to create it from the thread's Execute method. > - HttpCli.Multithreaded:= true OK. > - place a message pump in the thread's execute procedure. OK. > - create a hidden window to post message to Only if you need one for your own use. > Something else to do ? Start the event chain just before entering the message pump. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
Thanks for the fast response. However, I need all the items listed, including the hidden window. In the OnRequestdone event, I sometimes need to restart the the same operation which I can't do from within the onRequestDone event. I just wanted to know if there was something else I should do Paul -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] Program to thread
- Original Message - From: "Paul" <[EMAIL PROTECTED]> To: Sent: Monday, June 05, 2006 11:51 AM Subject: [twsocket] Program to thread > What is the correct way to convert an existing program with 1 HttpCli in > async mode to a thread? > > - HttpCli.create(nil) Necessary to be done in Execute(). > - HttpCli.Multithreaded:= true Necessary. > - place a message pump in the thread's execute procedure. Necessary. > - create a hidden window to post message to No need-auto done in both v5 and v6. Regards, SZ > > Something else to do ? > > Paul > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be