Problem fixed !

In OverbyteIcsHttpProt.pas, add:

{$IFDEF COMPILER2_UP}
procedure THttpCli.ThreadAttach;
begin
    inherited ThreadAttach;
    FCtrlSocket.ThreadAttach;
end;

procedure THttpCli.ThreadDetach;
begin
    inherited ThreadDetach;
    FCtrlSocket.ThreadDetach;
end;
{$ENDIF}

Don't forget to add the declarations in the public section.

In OverbyteIcsWndControl, add a line in ThreadDetach so that it looks like:
procedure TIcsWndControl.ThreadDetach;
begin
    if GetCurrentThreadID <> FThreadID then
        raise EIcsException.Create('Cannot detach from another thread');
    Self.DeallocateHWnd;
    FWndHandler := nil;                 // THIS ONE ADDED
end;


In OverbyteIcsWSocket.pas, delete the declaration of 
TCustomWSocket.FThreadID.

That's it.
Should work. At least it work in my small test prog:
Create a form, drop a TButton, a TMemo and a THttpCli. Add the following 
code:

unit OverbyteIcsSimpleThread1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket,
  OverbyteIcsHttpProt;

type
  TWorkerThread = class(TThread)
  public
      FHttpCli : THttpCli;
      procedure HttpCliRequestDone(Sender : TObject; RqType: THttpRequest; 
ErrCode : Word);
      procedure Execute; override;
      procedure ShowDoc;
  end;

  TForm1 = class(TForm)
    HttpCli1: THttpCli;
    DoButton: TButton;
    Memo1: TMemo;
    procedure DoButtonClick(Sender: TObject);
  private
    FWorkerThread : TWorkerThread;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TWorkerThread.Execute;
begin
    FHttpCli.ThreadAttach;
    FHttpCli.MultiThreaded := TRUE;
    FHttpCli.URL           := 'http://localhost';
    FHttpCli.RcvdStream    := TMemoryStream.Create;
    FHttpCli.OnRequestDone := HttpCliRequestDone;
    FHttpCli.GetASync;
    FHttpCli.MessageLoop;
    FHttpCli.ThreadDetach;
    FHttpCli.MultiThreaded := FALSE;
end;

procedure TWorkerThread.HttpCliRequestDone(Sender : TObject; RqType: 
THttpRequest; ErrCode : Word);
begin
    FHttpCli.RcvdStream.Seek(0, 0);
    Synchronize(ShowDoc);
    FHttpCli.RcvdStream.Free;
    FHttpCli.RcvdStream := nil;
    PostMessage(FHttpCli.Handle, WM_QUIT, 0, 0);
end;

procedure TWorkerThread.ShowDoc;
begin
    Form1.Memo1.Lines.LoadFromStream(FHttpCli.RcvdStream);
end;

procedure TForm1.DoButtonClick(Sender: TObject);
begin
    HttpCli1.ThreadDetach;
    FWorkerThread                 := TWorkerThread.Create(TRUE);
    FWorkerThread.FreeOnTerminate := TRUE;
    FWorkerThread.FHttpCli        := HttpCli1;
    FWorkerThread.Resume;
end;

end.
--
[EMAIL PROTECTED]
http://www.overbyte.be



----- Original Message ----- 
From: "Francois PIETTE" <[EMAIL PROTECTED]>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Monday, June 05, 2006 12:25 PM
Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem


> Yes, I found the problem. More complex to solve than what I thought first.
>
> --
> [EMAIL PROTECTED]
> http://www.overbyte.be
>
> ----- Original Message ----- 
> From: "Fastream Technologies" <[EMAIL PROTECTED]>
> To: "ICS support mailing" <twsocket@elists.org>
> Sent: Monday, June 05, 2006 11:37 AM
> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem
>
>
>> Francois,
>>
>> Have you been able to reproduce the problem there?
>>
>> Regards,
>>
>> SZ
>>
>> ----- Original Message ----- 
>> From: "Fastream Technologies" <[EMAIL PROTECTED]>
>> To: "ICS support mailing" <twsocket@elists.org>
>> Sent: Sunday, June 04, 2006 6:24 PM
>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem
>>
>>
>>> AFAIU, instead of FWindowHandle being defined as window, we now have the
>>> entire hierarchy being derived from a Twndcontrol which pools and shares
>>> the
>>> windows. But I am clueless in terms of this bug as well. I sent a 
>>> private
>>> email to Francois asking for consultancy about this.
>>>
>>> Thanks anyway,
>>>
>>> SZ
>>>
>>> ----- Original Message ----- 
>>> From: "Arno Garrels" <[EMAIL PROTECTED]>
>>> To: "ICS support mailing" <twsocket@elists.org>
>>> Sent: Sunday, June 04, 2006 6:06 PM
>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem
>>>
>>>
>>>> Fastream Technologies wrote:
>>>>> Nothing changes. This is my second answer to this question as
>>>>> sometimes my email server gets swamped :(...
>>>>>
>>>>> I still get the exception even though the package compiles with no
>>>>> errors.
>>>>
>>>> Looks like a bit more complicated. Francois probably knows better how
>>>> to fix it, I still haven't fully got the logic of the new version,
>>>> sorry.
>>>>
>>>>>
>>>>> Regards,
>>>>>
>>>>> SZ
>>>>>
>>>>> ----- Original Message -----
>>>>> From: "Arno Garrels" <[EMAIL PROTECTED]>
>>>>> To: "ICS support mailing" <twsocket@elists.org>
>>>>> Sent: Sunday, June 04, 2006 5:31 PM
>>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem
>>>>>
>>>>>
>>>>>> Fastream Technologies wrote:
>>>>>>> It is used here:
>>>>>>
>>>>>> Yes I know, but what happens? As Francois already supposed it
>>>>>> is in fact redefined and never assigned in TCustomWSocket.
>>>>>>
>>>>>>
>>>>>> ---
>>>>>> 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
>>>> -- 
>>>> 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
>
> -- 
> 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

Reply via email to