Hi!
I'd like the TIdHTTP events to be fired in the same thread as the Get()
method is running - especially the OnRedirect event. Is that possible
without inheriting TIdHTTP? If not, how can I keep the redirection logic
intact in my subclass?
class TIdHTTPUnsynchronizedEvents : public TIdHTTP {
protected:
virtual bool __fastcall DoOnRedirect(AnsiString &Location,
AnsiString &VMethod, int RedirectCount);
public:
inline __fastcall TTedHTTP(Classes::TComponent* AOwner) :
TIdHTTP(AOwner) { }
inline __fastcall virtual ~TTedHTTP(void) { }
};
bool __fastcall TIdHTTPUnsynchronizedEvents::DoOnRedirect(
AnsiString &Location, AnsiString &VMethod, int RedirectCount)
{
bool Handled=false;
if( OnRedirect ) {
OnRedirect(this,Location,RedirectCount,Handled,VMethod);
}
// what now? :-)
}
This feels like the wrong approach...
Br,
Ted
--
Windows 7 32bit | RAD Studio 2007 | Indy 10_4819
On 2014-06-19 17:03, Ted Lyngmo wrote:
> Hi!
>
> I'd like the TIdHTTP events to be fired in the same thread as the Get()
> method is running - especially the OnRedirect event.
Hmm, perhaps that's the way it's implemented already? Can I be so lucky? :-)
--
Windows 7 32bit | RAD Studio 2007 | Indy 10_4819
On 2014-06-19 17:36, Ted Lyngmo wrote:
> On 2014-06-19 17:03, Ted Lyngmo wrote:
> > Hi!
> >
> > I'd like the TIdHTTP events to be fired in the same thread as the Get()
> > method is running - especially the OnRedirect event.
>
> Hmm, perhaps that's the way it's implemented already? Can I be so lucky? :-)
I used GetCurrentThreadId() in the various places and it seems I am that
lucky. Forget this question :-)
Br,
Ted
--
Windows 7 32bit | RAD Studio 2007 | Indy 10_4819
Ted wrote:
> I'd like the TIdHTTP events to be fired in the same thread as the
> Get() method is running
They already are. You do not have to do anything special for that.
TIdHTTP (and most other Indy client components) do not use worker threads
internally, they run in whatever thread context uses them. That includes
event handlers.
A few Indy client components do have internal worker threads, such as TIdTelnet,
TIdCmdTCPClient, and TIdIPMCastClient.
> Is that possible without inheriting TIdHTTP?
Of course. Just assign handlers to the events normally. They will be triggered
in whatever thread context is calling TIdHTTP::Get().
--
Remy Lebeau (TeamB)